【发布时间】:2013-02-02 19:38:02
【问题描述】:
$('div').data('info', 1);
alert($('div').data('info'));
//this works
$('div[data-info="1"]').text('222');
//but this don't work
我正在 jquery 中创建元素。之后,我想添加属性“数据”。他喜欢并被添加,但在 DOM 中,这并不明显,我无法获取项目,使用
$('div[data-example="example"]').html()
【问题讨论】:
标签: jquery html custom-data-attribute