JavaScript Tutorial Series 42: Actions on custom attributes on labels

Source: Internet
Author: User
Tags html tags

1 Get Tag Properties

Syntax: Element.getattribute (' property name ') returns the value of the corresponding property if NULL is not returned.

// HTML<div id= "box" index= "0" ></div>//jsvar box = document.getElementById (' box '); var value = Box.getattribute (' index '//  0
2Set the value of a custom property
Syntax: element.setattribute (' property name ', ' property's value ') returns undefined
// HTML<div id= "box" ></div>//jsvar box = document.getElementById (' box box.setattribute (' index ', 0//JS code after execution is complete.) changes in HTML tags <div id= "box "index=" 0 "></div>
3Remove the value of a custom property

Syntax: element.removeattribute (' property name ') returns undefined

// HTML<div id= "box" index= "0" ></div>//jsvar box = document.getElementById (' box '); Box.removeattribute (' index '//JS code after execution Changes in HTML tags <div id= "box" ></div>

Note:

1 These three methods of manipulating custom properties allow you to manipulate not only custom properties, but also properties in the HTML specification

2 sets the value of the property, which is eventually converted to the form of a string

JavaScript Tutorial Series 42: Actions on custom attributes on labels

Related Article

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.