Or have one click handler and check for edit/save. Maybe like this (untested):
$(document).ready(function() { $('a').bind('click', function() { if($(this).is('.edit')) { alert('Edit'); return false; } else if($(this).is('.save')) { alert('Save'); return false; } }); }); Or maybe have an "editable" class and bind to 'a.editable' instead of 'a' so you can have the return false at the end of the function and not repeat it. All this talk of editing and saving, you might want to check out the jEditable plugin: http://www.appelsiini.net/~tuupola/javascript/jEditable/ --Erik On 6/8/07, Mike Alsup <[EMAIL PROTECTED]> wrote:
Here's one possible solution: $(document).ready(function(){ $('.edit').click(function(){ alert('Edit'); $(this).removeClass().addClass('save').unclick().click(saveHandler); return false; }); // you only need the following line if there are elements with // class == save when the doc is loaded $('.save').click(saveHandler); }); function saveHandler() { alert('Save'); return false; }; Mike On 6/8/07, Green Tea <[EMAIL PROTECTED]> wrote: > > Here is my code: > > <script type="text/javascript"> > $(document).ready(function(){ > // edit > $('.edit').click(function(){ > alert('Edit'); > $(this).removeClass().addClass('save'); > return false; > }); > // save > $('.save').click(function() > { > alert('Save'); > return false; > }); > }); > </script> > > <a href="test.htm" class="edit">Test</a> > > It always alert "Edit", but class changed to "save". > How i can get access to element with class "save"? > >