Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Idiomatic way of calling a jQuery function on a Javascript object?

Given a Javascript DOM object, what is the most idiomatic way of calling a jQuery function on it? Currently, I am using:

$('#' + object.id).someFunction()

However, this doesn't feel quite right. Isn't there a better way?

like image 977
user2398029 Avatar asked Aug 15 '26 09:08

user2398029


1 Answers

This should work

 $(object).someFunction();

You can see it live here: http://jsfiddle.net/XsKXU/

See this documentation for reference on the $ (aka jQuery) function

like image 199
Eran Medan Avatar answered Aug 17 '26 01:08

Eran Medan