I'm wondering if that's possible to get object property from element data.
So let's say I have element:
<div data-item="objProp" class="test">test</div>
And js object:
var obj = {
objProp: true
}
I tried to:
var test = $('.test').data('item');
alert(obj.test);
So, yeah, is there any way I can do this?
你似乎想要
alert(obj[test]);
Try to use []
:
alert(obj[test]);
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.