这里不是说的挺明白的么 http://api.jquery.com/attr/#a... function Type: Function( Integer index, String attr ) => String or Number A function returning the value to set. this is the current element. Receives the index position of the element in the set and the old attribute value as arguments. 比如你有个<div id="hello" world="2"></div>你想每次都给world自增1可以这么做 jQuery('#hello').attr('world',function(i,old){ return ~~old+1; }); ps:你不问我还不知道有这个回调呢,哈哈
这里不是说的挺明白的么 http://api.jquery.com/attr/#a...
比如你有个
<div id="hello" world="2"></div>
你想每次都给world自增1
可以这么做
ps:你不问我还不知道有这个回调呢,哈哈