tags:

views:

31

answers:

1

i have one function in jquery like this

   $("#Button_save").click(function() 
    {
 Save Command;

    });

this work fine with image

<img src="save.png" width="16" height="16" id="Button_save" style="cursor:pointer"/>

i want to call same function on text hyper link i use this

   <a href="#" onclick="javascript:Button_save();">SAVE</a>

but not working...

Thanks

+3  A: 
<a href="#" class="funcLink">Click Me</a>

--

$("a.funcLink").click(function(e){
  e.preventDefault();
  Button_Save();
});

--

One other thing you may consider is using a link this this <a href="enable-javascript.html" class="funcLink">Click Me</a> instead, which will inform the visitor that your site requires javascript to operate properly. Of course when Javascript is enabled, the javascript provided above will cancel out the default action, and the user will never know the enable-javascript page event exists.

It's a fall-back plan for good design.

Jonathan Sampson
not working, giving error
air
What error is it giving? Make sure you spell the function name correctly, and use proper casing.
Jonathan Sampson