I'm generating html tags with jQuery. Like this
jQuery:
$(document).ready(function() {
$('#example').DataTable();
var cas = ["1", "2", "3", "4", "5", "6"];
var text = "";
var i;
for (i = 1; i <= cas.length; i++) {
text += '<li class="noactive" ></li>';
}
jQuery("#bitacorapagination").html(text);
jQuery('.active').click(function () {
suplementos(this);
jQuery(".active").removeClass("active").addClass("noactive");
jQuery(this).removeClass("active").addClass("noactive");
console.log("Event");
});
jQuery('.noactive').click(function () {
suplementos(this);
jQuery(".active").removeClass("active").addClass("noactive");
jQuery(this).removeClass("noactive").addClass("active");
console.log("Event");
});
});
html code:
<ul>
<li id="bitacorapagination"></li>
<ul>
what I need is to remove and add some class to the <ul>
element generated by jQuery , but the event doesn't activate on the event onclick()
Do you have any idea how to solve this?