获取html5< data-something =" value">的值用jquery [英] get the value of html5 <data-something="value"> with jquery

查看:129
本文介绍了获取html5< data-something =" value">的值用jquery的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

前几天我正在阅读stackoverflow中的答案,我读到,jquery可以获得html5的价值< data-something ='value'> ,当我寻找其他东西时,我读到了这些,所以我只是阅读并且不分析这个。现在我真的需要完成这项任务。

The other day I was reading the answers here in stackoverflow and I read, "jquery can get the value of the html5 <data-something='value'>", I read this when I was looking for something else so I just read and don't analyse this. And now I really need accomplish this task.

问题是:它是否可行或者我只是误解了阅读?

The question is: is it posible or I just misunderstand the reading?

推荐答案

<div id="test" data-key="abcd">hahahah</div>

<script type="text/javascript">
var value = $("#test").data("key");
alert(value); //This will show you "abcd"
</script>

我认为数据不仅适用于HTML5,也适用于HTML4

I think data isn't only for HTML5 but also in HTML4

这篇关于获取html5&lt; data-something =&quot; value&quot;&gt;的值用jquery的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆