Onclick Function In Jquery Is Not Working
With the help of product_showcase.js file I am loading content into HTML and then on clicking the product link using the class of i.e inner I am trying to organize an onclick even
Solution 1:
You can add the event listener on the parent #electronics_products
$('#electronics_products').on('click', function(e){
if ($(e.target).attr('class') === 'inner') {
console.log("still here");
}
})
or
$('#electronics_products').on('click', '.inner', function() {
console.log("still here");
});
Solution 2:
My onclick event is in product_description.js file while onclick event was happening on product_showcase.html where product_description.js file was not mentioned in script. So either
- I had to mention that on product_showcase.html page or
- transfer the onclick function code to the product_showcase.js file.
Post a Comment for "Onclick Function In Jquery Is Not Working"