Reputation: 18601
I want to select field with following condition
Id start with Product
OR
Id start with Product and Hidden field
My following code will only satisfy first condition I also want to satisfy 2nd condition. How is possible?
$("input[id^=Product]").each(function(){
alert($(this).attr("id"));
});
Thanks for help.
Upvotes: 1
Views: 122
Reputation: 206689
$('input[id^=Product]:hidden')
http://api.jquery.com/hidden-selector/
http://api.jquery.com/attribute-starts-with-selector/
If you really want an OR
in the means target both with idStartsWith and idStartsWith+it'sHidden do like:
$('input[id^=Product], input[id^=Product]:hidden')
Upvotes: 2
Reputation: 28523
Try this : You can use multiple attribute selector for input hidden type, put [type='hidden']
in selector
$("input[type='hidden'][id^=Product]").each(function(){
alert($(this).attr("id"));
});
EDIT - As OP want to satisfy both condition. You can use comma separated selectors for this. Put your earlier selector with comma separated above selector. See code below -
$("input[id^=Product],input[type='hidden'][id^=Product]").each(function(){
alert($(this).attr("id"));
});
Upvotes: 2