Title: Create List using JSOM
List name: CustomerList
Steps: Open the Site and create the page
Edit the page and add below code Script Edit webpart.
<html>
<head>
<script type="text/javascript" src="http://code.jquery.com/jquery-1.7.1.min.js"></script>
<script type="text/javascript" src="https://ajax.aspnetcdn.com/ajax/4.0/1/MicrosoftAjax.js"></script>
<script type="text/javascript" src="/_layouts/15/init.js"></script>
<script type="text/javascript" src="/_layouts/15/sp.runtime.js"></script>
<script type="text/javascript" src="/_layouts/15/sp.js"></script>
<script type="text/ecmascript">
function createList() {
var clientContext = new SP.ClientContext.get_current();
var oWebsite = clientContext.get_web();
var listCreationInfo = new SP.ListCreationInformation();
listCreationInfo.set_title('CustomerList');
listCreationInfo.set_description('description');
listCreationInfo.set_templateType(SP.ListTemplateType.genericList);
oWebsite.get_lists().add(listCreationInfo);
clientContext.executeQueryAsync(
Function.createDelegate(this, this.onQuerySucceeded),
Function.createDelegate(this, this.onQueryFailed)
);
}
function onQuerySucceeded() {
alert("List Created");
}
function onQueryFailed(sender, args) {
alert("List Failed");
}
</script>
</head>
<body>
<p>Click the following button to see the result: </p>
<form>
<input type="button" value="Click Me" onclick="createList();" />
</form>
</body>
</html>