Reputation: 13
There is a following problem with JS and jquery. During one of the events happening on the page:
task = $("#id").html();
$("#video_id").html(task);
$("#id").html("");
After that, the buttons from #id doesn't work in #video_id.
I've tried to send the data from #video_id back to the old place and process the events there
task = $("#video_id").html();
$("#id").html(task);
$("#video_id").html("");
But after that stopped working all buttons inside the #id.
How to make the elements within the task correctly processed when transferred to #video_id?
Upvotes: 1
Views: 92
Reputation: 294
If you're binding the events to the buttons with jquery you would need to bind the events during the copy process for this to work.
Or use the $(document).on() method...
<div id="one"><button class="two">test</button></div>
<div id="three"></div>
$(document).on('click', '.two', function(){
alert("test");
var test = $('#one').html();
$('#three').html(test);
});
This will bind the event to new elements dynamically added to the DOM.
Upvotes: 1