I have added JSOM/js code using Content Editor to a SharePoint page. The js code is retrieving list items and binding it to a ul and divs. And the ul forms the jQuery tabs. But my problem here is tabs functionality is not working i.e li onclick event is not triggered at all. I am not sure what I am missing. Below code is just a skeleton of actual code.
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
<script>
$(document).ready(function(){
ExecuteOrDelayUntilScriptLoaded(getItems, "sp.js");
function getItems() {
//Get list items and onSuccess bind to ul
}
$("ul.tabs li").click(function(){
// Switch between tabs
});
});
</script>
Update: Sorry for not providing full code here.Anyway when the getItems and switch tabs functions are separately been used they are working with no issues, and I already have them in other pages. but here in this page SharePoint is not loading click method. As some answers suggested, i have already tried on('click'... before posting question here.
$("ul.tabs li").click(function(){ console.log("click is fired"); });
and hit enter. Now see if click event is firing. Also make sure the tabs class exists on ul.