patipat chewprecha patipat chewprecha - 10 months ago 50
HTML Question

function clicked not work for me on adminLTE

I got this problem about all night. I will click button and I got nothing data or alert. Please help me. And so Sorry for my bad English.I'll try to learn.

<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.6.1/jquery.min.js"></script>
<script>
$(document).ready(function(){
$("#test-click").on("click",function(){
alert('1');
});
});

</script>
<button type="button" id="test-click">testClick</button>

Answer Source

Yes OfCourse! your code is not working. because .on() event comes after jquery 1.7.x versions. Please use .live() event instead of .on() event. Or else use latest jquery version.

<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.6.1/jquery.min.js"></script>
<script>
    $(document).ready(function(){
    $("#test-click").live("click",function(){ 
        alert('1');
    });
    });

</script>
<button type="button" id="test-click">testClick</button>