remove() tag script asynchronus non remove events in js.
Regards for all.
My story is this. In a head on html5 page, there is an script tag with jquery "on click events", like this:
- <head>
- <script src="js/jquery.min.js"></script>
- <script src="js/jquery-ui.min.js"></script>
- <script src='js/main.js' class="fnjq"></script>
- </head>
the file main.js:
- $(document).on('click','#btnsecc',function(event) {
- alert('has press the button btnsecc');
- });
with a button remove the tag script for main.js:
- $(document).on('click','#producto',function(event) {
- $('head').find('.fnjq').remove();
- });
the tag is removed from the DOM, and the result is:
- <head>
- <script src="js/jquery.min.js"></script>
- <script src="js/jquery-ui.min.js"></script>
- </head>
but the events in the file main.js continue active, for example the event click in
#btnsecc continue active, and pressed button
#btnsec active the alert message.
I want to implement a remove() in tag script, remove the tag and the events in main.js.
Really appreciate any help
Thanks in advance