JS 总结

jquery使页面中所有select选中第一个option:

 

/方法一,支持低版本的jquery.js
var a = document.getElementById("mySelect");//mySelect是select 的Id
a.options[0].selected = true;
//方法二,jquery1.6中新加了一个方法prop(),因此使用prop()时请使用jquery1.6及以上版本
$("#mySelect option:first").prop("selected", 'selected');



//清空表单 input 和 textarea 的值 , formId 是你自己表单的id(即 form id)
$("#formId").find("input[type='text'],textarea").each(function(){
           this.value = "";
});

 

posted @ 2016-08-19 18:16  经历无法倒带  阅读(100)  评论(0编辑  收藏  举报