jQuery reset all select fields

/ Published in: jQuery
Save to your folder(s)

Couldn't find a better way to do this, nor could I find it on teh interwebs, so here it is.

Copy this code and paste it in your HTML
  1. // for each select field on the page
  2. $("select").each( function(){
  3. // set its value to its first option
  4. $(this).val( $("#" + $(this).attr("id") + " option:first").val() );
  5. });

Report this snippet


RSS Icon Subscribe to comments

You need to login to post a comment.