Reputation: 6264
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
Upvotes: 0
Views: 106
Reputation: 268334
<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.
Upvotes: 3