Jquery的集合方法EACH()
Jquery的集合方法EACH()
1、
$("input[name='r2']").each(function(){
??? if($(this).val()=='lmf')
??? {
??????? this.checked = true;
??? }??
})
2、
$("input[name='r2']").each(function(){
??? this.checked = this.value == "lmf";
})
3、
$("input[name='r2']").each(
??? function(i,item){
??????? if(item.value=='lmf')
??????? {
??????????? item.checked = true;
??????? }
??? }
)
4、
$.each(list,function(i,item){
})
有時候function的參數不能省略:
???????? if(!StringUtils.IsNullOrEmpty(liveStatus))
???????? {
???????????? lives = liveStatus.split(",");
???????????? var len = lives.length;
???????????? var i = 0;
???????????? for(i=0;i<len;i++)
???????????? {
???????????????? $("input[name='ck_LiveStatus']").each(
???????????????????? function(k,item) {
???????????????????????? if(item.value == lives[i])
???????????????????????? {
???????????????????????????? item.checked = true;
???????????????????????? }
???????????????????????? //this.checked = this.value == lives[i];因為里面有i變量不可以用這一句話
???????????????????? }
???????????????? );
???????????? }
????????? }?
總結
以上是生活随笔為你收集整理的Jquery的集合方法EACH()的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 背景半透明最佳实践
- 下一篇: Web服务器启动端口冲突问题