javascript - use selectors in variable jquery -


i have made functionality this on click of link show product details in popup box using big jquery code didn't understand

and here jsfiddle trying give links same class different #tags show div , want when click on link resolves href value of same , show corresponding result didnt works can suggest right way here js

$(".show").click(function() {     var link = $('this').attr('href');   $(link).show();  }); 

and html

<a href="#popup" id="show" class="show">a</a> <a href="#popup1" id="show1" class="show">b</a> <a href="#popup2" id="show2" class="show">c</a> 

i want show #popup on anchor click

full code on fiddle , want this functionality

you should call $(this), not $('this')

  • $(this) wraps object referred this inside jquery object,
  • $('this') traverse of document looking html nodes tagged this (much $('div') html nodes tagged div); since there isn't any, select empty list of nodes.

working fiddle : http://jsfiddle.net/hg4zp/3/

( there typo, calling .hide(") instead of .hide() )


Comments

Popular posts from this blog

get url and add instance to a model with prefilled foreign key :django admin -

css - Make div keyboard-scrollable in jQuery Mobile? -

ruby on rails - Seeing duplicate requests handled with Unicorn -