Events selector for various attributes

I am aware of using ids and classes for events as follows

click #somethings' :

and

click .somethings' :

Now, i want to trigger and event using name attribute. I tried as follows, but no luck

click $('[name="something"]')' :

can anyone tell me the right way?

"click $('[name=\'something\']')"

Watch the quotes

I copy pasted your exact code, just changed the "something to what It needs to be, I am getting the following error

Error: Syntax error, unrecognized expression: $(’[name=‘inculdebox’]’)

any idea whats wrong?

'click $("[name=\'something\']")'

try this

'click [name="something"]'

The selector portion of your event hook is passed into jQuery by Meteor, so you don’t have to do that yourself. Trying to do that within the string doesn’t actually accomplish anything other than malforming your selector.

2 Likes

Thank you, This works