Posted By

sveggiani on 07/02/09


Tagged

jquery not-mine


Versions (?)

Who likes this?

1 person have marked this snippet as a favorite

maxvee8


manage select boxes with jQuery


 / Published in: JavaScript
 

URL: http://elegantcode.com/2009/07/01/jquery-playing-with-select-dropdownlistcombobox/

  1. // Get the value of the selected item
  2. $("#ComboBox").val();
  3.  
  4. // Get the text of the selected item
  5. $("#ComboBox option:selected").text()
  6.  
  7. // Find out when the select value changed
  8. $("#ComboBox").change(function() { /* do something here */ });
  9.  
  10. // Programmatically set the selected item.
  11. $("#ComboBox").val(2);
  12.  
  13. // Modify the list
  14. // Clear the list:
  15. $("#ComboBox").html("");
  16.  
  17. // Add to the list:
  18. $("<option value=’9’>Value 9</option>").appendTo("#ComboBox");

Report this snippet  

You need to login to post a comment.