在HTML中data-value和value有什么区别?

HTML

杨天栾

2018-10-24

<form>
<input type="text" name="myname" data-value="dhoni" value="sachin">
</form>

在HTML中data-value和value有什么区别?

 

第79篇《在HTML中data-value和value有什么区别?》来自Winter(https://github.com/aiyld/aiyld.github.io)的站点

1个回答
杨天栾 2018.10.24
They are both attributes, but the value attribute (together with name attribute) can be natively accessed by most server-side languages. Whereas data-value can only be natively accessed by the client-side. Data attribute can also have different suffix, you could name it; data-name, data-email, data-content, and etc. You could say it's "customizable".

问题类别

JavaScript Ckeditor Python Webpack TypeScript Vue.js React.js ExpressJS KoaJS CSS Node.js HTML Django 单元测试 PHP Asp.net jQuery Bootstrap IOS Android