问题标签 [jquery-data]
For questions regarding programming in ECMAScript (JavaScript/JS) and its various dialects/implementations (excluding ActionScript). Note JavaScript is NOT the same as Java! Please include all relevant tags on your question; e.g., [node.js], [jquery], [json], [reactjs], [angular], [ember.js], [vue.js], [typescript], [svelte], etc.
javascript - jquery 数据与 dom 属性不匹配
我对 jquery 数据函数有一个奇怪的问题。这是小提琴
如您所见,我更新了active
数据,但看不到 domdata-active
属性值更改,尽管我重新查询了活动数据,但它写入了更改的值。$.data() 在我检查时不更新 dom 上的属性。
javascript - jquery .data 函数与在 html 中设置数据值
如果我使用 jquery$("#my_button").data('my-value', { onClick: function () { my_obj_function(); } });
在另一个功能中我这样做
my-value.onClick.call()
有用。
但是如果我尝试在 html 中设置数据属性,它就不起作用。我在 html 中做了这个
<a href='#' data-my-value='{"onClick":"function () { my_obj_function(); }"}'>Click me</a>
当calling my-value.onClick.call()
我得到
uncaught typeerror : object function() has no method call
我究竟做错了什么?
javascript - IE7 中的 jQuery data() 支持
我有以下代码;
现在这里的“数据”代表一个 Div 或 DOM 元素,我附加了一些数据属性(或对象)。
因此 $(data).data() 在所有浏览器(包括 IE9)中都可以正常工作……但在 IE7 中却不行。
有一些解决方法吗?
javascript - jquery自定义数据属性在div标签内不起作用
我正在使用这个 div 代码
并尝试打印像
如果我将上面的 div 标签直接放在 body 中,这可以正常工作,但是当我将 div 标签放在任何其他 div 标签中时,它不起作用并显示未定义。
控制台为上面的 html 打印 undefined。
如果有什么不清楚的地方请告诉我
javascript - how to set property within property in jQuery data()
If I know that a certain data property exists on an element and it is an object, how can I store something as a new property of that data object?
For example, I have this div:
And I'm trying to set data on it like this:
But that is getting me nowhere. And div.data(["test1"]["number"]) = 1;
gets me a left-hand side in assignment error.