Reputation: 1115
<input type="text" someCustomAttr="value"></input>
This code sometimes work sometimes not:
$fields = $('input[someCustomAttr="value"]','#contaners_id');
Is this ok?
Upvotes: 0
Views: 40
Reputation: 93223
It should work :
<input type="text" someCustomAttr="value" value="fdfgfdg"></input>
<div></div>
If it isn't worked yet, Change Jquery lib version and Use one such as used by jsfiddle in this demo : http://jsfiddle.net/abdennour/UYTKr/
Upvotes: 0
Reputation: 71
If you want just the attribute and don't care about the value, then do:
$fields = $('input[data-custom]');
Additionally, if you want elements besides inputs that also have that attribute, then just do:
$fields = $('[data-custom]');
Upvotes: 0
Reputation: 18891
someCustomAttr="value"
to data-custom="value"
.$('input[data-custom="value"]);
Upvotes: 3