[jQuery Note]jQuery element properties and attributes

 

CodeDescriptionExample
attr(name)Obtains the value assigned to the specified attribute for the first element in the matched set$('#myImage').attr('title');
attr(name,value)Sets the named attribute to the passed value for all elements in the wrapped set.$('#myImage').attr('title','This is titile.');
attr(attributes)Uses the properties and values specified by the passed object to set corresponding attributes onto all element of the matched set.$('myImage').attr({title:'This is title,alt:'This is alt''})
removeAttr(name)Removes the specified attribute from every matched element. 
data(name,value)Adds the passed value to the jQuery-managed data store for all wrapped elements.(Returns a wrapped set) 
data(name)Retrieves any previously stored data with the specified name on the first element of the wrapped set. 
removeData(name)Removes any previously stored data with the specified name on all elements of the wrapped set. 
addClass(names)  
removeClass(names)  
toggleClass(names)Adds the specified class name if it doesn't exists on an element, or removes the name from elements that already possess the class name.Note that each element is tested individually,so some elements may have the class name added,and others may have it removed.
Yes.this funtion() is fit for the list when you move your mouse on and mouse out.
 
toggleClass(name,switch)  
hasClass(name)  
css(name,value)  
css(properties)  
width(value)||height(value) $('div.myElements').width(500);
offset()  
position()  
 
 
Attention1:
     When we want to set element in disable state,we often use of the attr() method like this:
     $('form').submit(function{
          $(':submit',this).attr('disabled','disabled')
     })
Attention2:
     I think that data() and removeData()  function  like request.setAttribute() and request.getAttribute();

转载于:https://www.cnblogs.com/Xuhaiyang/archive/2012/07/12/2588410.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值