jQuery重置所有选择字段

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了jQuery重置所有选择字段相关的知识,希望对你有一定的参考价值。

Couldn't find a better way to do this, nor could I find it on teh interwebs, so here it is.
  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. });

以上是关于jQuery重置所有选择字段的主要内容,如果未能解决你的问题,请参考以下文章