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

Popular posts from this blog

delphi - How to convert bitmaps to video? -

jasper reports - Fixed header in Excel using JasperReports -

python - ('The SQL contains 0 parameter markers, but 50 parameters were supplied', 'HY000') or TypeError: 'tuple' object is not callable -