Skip to content Skip to sidebar Skip to footer

Maintain Jquery Onchange After A Replacewith

I have some code that grabs the first select on the page and clones it so that I can reset it later on if needed. mySelect = jQuery('select').get(0); origSelect = jQuery(mySelect).

Solution 1:

Pass a parameter true to the clone method.

origSelect = jQuery(mySelect).clone(true); //This will clone the select with data and events

or replace the innerHTMl of origSelect with that of mySelect.

jQuery(origSelect).html(jQuery(mySelect).html()); 

Solution 2:

Post a Comment for "Maintain Jquery Onchange After A Replacewith"