i have following button:
<button type="button" class="start-upload-btn">Start Uploading</button>
I'm adding a click listener to it within the script tags:
<script>
$(document).ready(function() {
alert(jQuery);
$('.start-upload-btn').on('click', function() {
alert(jQuery);
var myData = ${dataForUpload};
if (myData) {
$.each($.parseJSON(myData), function(key,value){
alert(value.oldFile);
});
}
else {
alert('No Data');
}
});
});
</script>
The alert(JQuery); within the click function does not work on clicking. I can't figure out what's the matter with my code.
Update: i'm using this cdn for JQuery in head.
<script src="https://code.jquery.com/jquery.min.js"></script>
I've updated my code with ready function, but it still isn't working.
$(function() { /* your code here */ });