Neeraj Kumar Gupta
Neeraj Kumar Gupta

Reputation: 2363

JQuery selector by custom attribute value and element type

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'.

Upvotes: 3

Views: 2457

Answers (1)

adeneo
adeneo

Reputation: 318202

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

Upvotes: 5

Related Questions