JQuery拿取对象的方式
$(‘#id') :通过元素的id
$(‘tagName') : 通过元素的标签名
$(‘tagName tagName') : 通过元素的标签名,eg: $(‘ul li')
$(‘tagName#id): 通过元素的id和标签名
$(‘:checkbox'):拿取input的 type为checkbox'的所有元素:
Eg:
<input type="checkbox" name="appetizers" value="imperial"/>$('span[price] input[type=text]') :拿取下面的input元素<span price="3"><input type="text" name="imperial.quantity" disabled="disabled" value="1"/></span>$('div',$(this).parents('div:first')):拿取该div的上(至少都是父节点)的第一个div节点$('~ span:first',this): locates the first sibling of this that's a <span> element.延迟加载js文件:
$.getScript
例子:
Html文件:
Java代码
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http:///Utilities/jQuery.unique alert(); $.each(arr2,function(n,value) { //do something here alert(n+' '+value); }); }); </script></head><body><div>First</div><div>Second</div><div>Third</div><div>Fourth</div><div>Fourth</div></body></html>以上这篇jquery 遍历数组 each 方法详解就是小编分享给大家的全部内容了,希望能给大家一个参考,也希望大家多多支持。