Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

JQuery selector by custom attribute value and element type

Tags:

jquery

I need to select the element by custom attribute value where the element type should be image. I know the following selectors to get the element

By element type

var imgElms = $("input[type=image]");

By custom attribute

var cusElms = $("input[myAttr='org']");

I need mix of both selector to get all image element that has custom attribute myAttr='org'.

like image 838
Neeraj Kumar Gupta Avatar asked Jun 07 '26 14:06

Neeraj Kumar Gupta


1 Answers

You'd mix them by simply using both, like this

$("input[type=image][myAttr='org']")

but note that myAttr is not a valid attribute, and you should be using data-attributes instead

like image 148
adeneo Avatar answered Jun 09 '26 05:06

adeneo



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!