javascript - How to hide element using "this"? -


pardon stupidity can please explain me how can hide element using this keyword? example working:

jquery(document).ready(function($){     if($('.someclass').length==1){         $('.someclass').hide();     }   }); 

but no go me:

jquery(document).ready(function($){     if($('.someclass').length==1){         $(this).hide();     }   }); 

thank you!

do need use this (in case, see other answers) or seek avoid selector duplication? this?

jquery(document).ready(function($){   var elem = $('.someclass');   if(elem.length == 1){     elem.hide();   }   }); 

Comments

Popular posts from this blog

c++ - Function signature as a function template parameter -

algorithm - What are some ways to combine a number of (potentially incompatible) sorted sub-sets of a total set into a (partial) ordering of the total set? -

How to call a javascript function after the page loads with a chrome extension? -