How to judge html's custom attribute has the one property in jquery -
i have define custom attribute called "data-children",use as:
<div data-children=“test01 test02 test03”></div>
but how can judge property has "test04":
var $collection=$('div').attr('data-children') ……//then can do?
since returns string, can use match method of string object. suggest using data method, though, if possible.
if ($('div').data('children').match(/(^|\s+)test04(\s+|$)/)) { }
Comments
Post a Comment