javascript - Div using jquery -


here working on listbox , iterating elements of listbox. here 'list2' id of listbox , elements of taken 'list2' :

 $(function(){     $("#button1").click(function(){          $("#list1 > option:selected").each(function(){             $(this).remove().appendto("#list2");          });     });      $("#button2").click(function(){         $("#list2 > option:selected").each(function(){             $(this).remove().appendto("#list1");          });     }); }); 

here made button3 show elements of 'list2'. click on show using div 'placeholder;

  $("#button3").click(function(){          var count = $("#list2 option").length;             $("#list2 > option").each(function() {            document.getelementbyid("error").style.display='none';            document.getelementbyid("placeholder").style.display='block';            document.getelementbyid("placeholder").innerhtml= document.getelementbyid("placeholder").innerhtml+'<p>'+this.text+'</p>'; }); 

here if click on 'button3' getting expected result if again click on button3 show again same result @ different location. number of times click on button show number of display/result @ different-different location.

i want result single time.

ques: there way achieve this.if click on button3 , elements same won't print more if change elements of list2 , show changed result.

thanks


Comments

Popular posts from this blog

c++ - CryptStringToBinary API behavior -

c++ - Correct method for redrawing a layered window -

java.util.scanner - How to read and add only numbers to array from a text file -