jQuery click event not firing on AJAX loaded HTML may you helpthis is my code but not working$documentonclickcj_dislikefunctione epreventDefault; alertdslike; var post_id = jQuerythisattrdata-
There are a few possible reasons why the click event is not firing on AJAX loaded HTML:
-
The HTML element with the class "cj_dislike" may not exist in the DOM at the time the event handler is attached. In this case, you need to make sure that the AJAX request has finished and the HTML element is added to the DOM before attaching the event handler.
-
The parent element of the HTML element with the class "cj_dislike" may have been replaced or modified by the AJAX request, causing the event handler to no longer be attached to the correct element. In this case, you may need to attach the event handler to a higher-level parent element that is not modified by the AJAX request.
-
There may be a syntax error or other issue in the code that is preventing the event handler from working properly. In this case, you need to debug the code and identify the specific problem.
To debug the issue, you can try adding console.log statements to the code to see if the event handler is being attached and if the variables are being set correctly. You can also use the browser's developer tools to inspect the HTML and JavaScript code and see if there are any errors or issues.
原文地址: https://www.cveoy.top/t/topic/bEk5 著作权归作者所有。请勿转载和采集!