我正在尝试使用jquery在我的元素上添加自定义属性:
$('.map-areas-div').rand(numElements).each(function(){
$(this).attr('element_id',4);
});
Run Code Online (Sandbox Code Playgroud)
但最后,我的元素没有"element_id"属性.
PS,我的html元素看起来像:
<div type="ground" class="map-areas-div" style="position: absolute; top: 900px; left: 720px; height: 40px; width: 90px;"></div>
Run Code Online (Sandbox Code Playgroud)
谢谢你的帮助