1

Is it possible to refer to original list by this or other variable. Lets say I have code like this:

$('input').focus(function(){
    $(this).css('border','solid 10px');
});

This will make any input that has focus its border thicker, but I want all inputs border to be thicker when anyone of the inputs has focus that were in the list. I know it can be done by reselecting all inputs, but for efficiency sake is there any variable that lets you access original jquery list inside event handler.

Xm7X
  • 861
  • 1
  • 11
  • 23
Muhammad Umer
  • 17,263
  • 19
  • 97
  • 168

1 Answers1

2

You don't do it with $(this). You just store the inputs in a variable at first then do all you need

var $inputs = $('input');

$inputs.focus(function(){
    $inputs.css('border','solid 10px');
});
Huangism
  • 16,278
  • 7
  • 48
  • 74
  • ok yea wow..my brain slow much. anyways still is there no built in variable for jquery? – Muhammad Umer Nov 24 '14 at 16:29
  • Not for what you are trying to do, even when you do `$(this)`, it is still creating a new jquery object. In your case, you just need to cache the inputs – Huangism Nov 24 '14 at 16:33