JQuery遍历控件的方法
?在本人的網站交友樂上需要點擊一個重置按鈕,將所有的checkbox設置為未選中,采用遍歷的方法來完成
控件如下
<button id="ClearPosition" type="button">清空職位</button>
<input type="checkbox"?? class="jobPostaJoblist"/><span>導購/促銷</span>
<input type="checkbox"?? class="jobPostaJoblist"/><span>收銀員</span>
?<input type="checkbox"?? class="jobPostaJoblist"/><span>店長</span>?????????????
JQUERY代碼如下:
jobPostaJoblistSelected是checkbox被選中時的css
stopDefault函數用于中止默認的事件響應
?$("#ClearPosition").each(function(i) {
????????????? $(this).click(function(e) {
????????????????? $("input[class*='jobPostaJoblist']").each(function(i) {
????????????????????? $(this).attr("checked", false);
????????????????????? $(this).next().removeClass("jobPostaJoblistSelected");
????????????????? });
????????????????? return stopDefault(e);
????????????? });
????????? });
????????? function stopDefault(e) {
????????????? if (e && e.preventDefault) {
????????????????? e.preventDefault();
????????????? } else {
????????????????? window.event.returnValue = false;
????????????? }
????????????? return false;
????????? }
?
轉載于:https://blog.51cto.com/jyoule/480888
總結
以上是生活随笔為你收集整理的JQuery遍历控件的方法的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 头部眉毛上面和太阳穴位置有伤口缝针过后两
- 下一篇: android组件通讯 Intent-