Thursday, May 23, 2024
 Popular · Latest · Hot · Upcoming
125
rated 0 times [  126] [ 1]  / answers: 1 / hits: 19365  / 14 Years ago, fri, july 30, 2010, 12:00:00

How can I pass the $this (the self keyword) to a function in Jquery



$(document).ready(function() {

$('.nav a').click(function() {
var direction = $(this).attr(name);
submit_form($(this))
});

function submit_form(this)
{
// do some stuff with 'this'
}
});

More From » jquery

 Answers
142

Wrapping it in $() makes it a jQuery object. You would want to do something like



submit_form(this);

function submit_form(obj)
{
// Work with `obj` as this
// Or wrap it in $() to work with it as jQuery(this)
}

[#96067] Wednesday, July 28, 2010, 14 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
morrismilom

Total Points: 230
Total Questions: 96
Total Answers: 114

Location: Mayotte
Member since Mon, Sep 12, 2022
2 Years ago
;