Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to reset the div tag in jquery
    primarykey
    data
    text
    <p>I have a drop down box in my html page where I need to reset the drop down list back to its original state. My code snippet is as follows:</p> <pre><code>&lt;div id="countries" &gt; &lt;!---------------I select a particular module-----------------&gt; &lt;select id="modules" onchange = "getRole()"&gt; &lt;!--Function getRole() called here--&gt; &lt;option&gt;---Select---&lt;/option&gt; &lt;option value="1"&gt;Module1&lt;/option&gt; &lt;option value="2"&gt;Module2&lt;/option&gt; &lt;option value="3"&gt;Module3&lt;/option&gt; &lt;option value="4"&gt;Module4&lt;/option&gt; &lt;/select&gt; &lt;!-Based on the modules some processing is done and countries are displayed-&gt; &lt;select multiple="multiple" id="country" name="country[]"&gt; &lt;option value="1"&gt;India&lt;/option&gt; &lt;option value="2"&gt;USA&lt;/option&gt; &lt;option value="3"&gt;Russia&lt;/option&gt; &lt;/select&gt; &lt;/div&gt; </code></pre> <p>I need reset the drop down menu after doing some processing</p> <p>In other words I need to get back my original state after doing all the processing using my drop down. </p> <p>I m using .clone() but that dosen't seem to be working.</p> <pre><code>function getRole() { //CLone the id 'countries' var cloneobj = $('#countries').clone(); //Some processing here .... //After processing get back the original state $('#countries').replaceWith(cloneObj); } </code></pre> <p>The problem here is clone is creating duplicate id's and hence dosent seem to be the right solution. Can anyone help. Please</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload