HTML data XX and data() precautions

Time:2020-2-13

1. Data XX naming: XX can contain “-” and “”, butNo capital letters;

2. When using $ele. Data() to get the value, the prefix of “data -” is not required: $ele. Data (‘xx ‘);

3. The difference between $ele. Data() and $ele. Attr():

1) The value of data () is saved in jQuery heap memory, and the value of attr () is saved in DOM element;

2) Changing the value of the attribute through data () will only change the value in jQuery heap memory, and will not affect the value of the attribute in DOM element;

3) By changing the value of the attribute through attr (), you can directly change the value of the attribute in the DOM element.

Recommended Today

What is Baidu’s secure openrasp project?

What is Baidu‘s secure openrasp project? In the history of this article, the official account is from the public technology. Welcome to redistribute and share knowledge, and respect copyright tagging authors and sources. At the end of the conversation, c0debreak opened a “confidential document” for me to see. It’s a secret that a otaku has […]