Events selector for various attributes


#1

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?


#2

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

Watch the quotes


#3

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?


#4

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

try this


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


#6

Thank you, This works