attr() 方法设置或返回被选元素的属性值
用于检索 HTML 属性
attr(属性名称|作为属性的“名/值对”对象|key,val属性名称,属性值|function(index, attr)第一个参数为当前元素的索引值,第二个参数为原先的属性值。)
&('id').attr("lay-id", item.id);
trim()方法去掉空格
password:$.trim($('#username').val())
each() 方法规定为每个匹配元素规定运行的函数。
$(selector).each(function(index,element))
$("button").click(function(){
$("li").each(function(){
alert($(this).text())
});
});
append() 方法在被选元素的结尾插入指定内容。
$(selector).append(content,function(index,html))
cite 标签
可以用来包裹动态添加的目录
$('id').append("<cite>" + item.title + "</cite>");
$.inArray() 函数
用于在数组中查找指定值,并返回它的索引值(如果没有找到,则返回-1)
**提示:**源数组不会受到影响,结果只反映在返回的结果数组中。
语法: 选择器.inArray('要查找的值', '要查找的数组','(可选)指定从数组的指定索引位置开始查找').
<div>"John" 在索引值为 <span></span> 的位置被找到</div>
var arr = [ 4, "Pete", 8, "John" ];
$( "span" ).inArray( "John", arr )
next()方法
获得共享同一个父亲的下一个同级元素
<ul>ul (父节点)
<li class="start">li (类名为"start"的兄弟节点)</li>
<li>li (类名为"start"的li节点的下一个的兄弟节点)</li>
</ul>
$("li.start").next();