jquery Action Properties

Source: Internet
Author: User

1. Setting individual properties
//第一个参数:需要设置的属性名//第二个参数:对应的属性值attr(name, value);//用法举例$("img").attr("title","哎哟,不错哦");$("img").attr("alt","哎哟,不错哦");
2. Setting multiple properties
//参数是一个对象,包含了需要设置的属性名和属性值attr(obj)//用法举例$("img").attr({    title:"哎哟,不错哦", alt:"哎哟,不错哦", style:"opacity:.5"});
3. Get Properties
 //to get the property name, return the corresponding property value attr (name) //usage Example var otitle = $ ( "img"). attr ( "title" ); alert (otitle);        

note:

    • When you get a property, you get only the property that corresponds to the first element, just like the CSS method

"Case: Beauty Album"

4. Removing attributes
//参数:需要移除的属性名,如果传空,那么不会有任何操作,注意,并不是移除所有的属性。区分removeClass。removeAttr(name);//用法举例$("img").removeAttr("title");
Prop Method

note:

//设置属性$(":checked”).prop("checked",true);//获取属性$(":checked").prop("checked");//返回true或者false

jquery Action Properties

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.