Skip to content Skip to sidebar Skip to footer

Using The Closure Scope To Keep The Last Value

I have the following: $('th').click(function() { var $th = $(this); ... }); Using the closure scope, I want to say: var $th; $('th').click(function() { if ($th !== $(this

Solution 1:

You should check whether the underlying DOM elements are equal:

if ($th[0] !== this) {

(You could also store this itself without calling $)


Post a Comment for "Using The Closure Scope To Keep The Last Value"