Can I add custom attribute to HTML tag like this: <tag myAttri="myVal" />
相关问题
- Views base64 encoded blob in HTML with PHP
- Is there a way to play audio on a mobile browser w
- HTML form is not sending $_POST values
- implementing html5 drag and drop photos with knock
-
Why does the box-shadow property not apply to a
The
jquery
data()
function allows you to associate arbitrary data with dom elements. Here's an example.You can do something like this to extract the value you want from javascript instead of an attribute
In HTML5: yes: use the data- attribute.
Yes, you can, you did it in the question itself:
<html myAttri="myVal"/>
.You can set properties from JavaScript.
You can add custom attributes to your elements at will. But that will make your document invalid.
In HTML 5 you will have the opportunity to use custom data attributes prefixed with
data-
.