Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    New Coder
    Join Date
    Sep 2005
    Posts
    45
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Changing A attributes onclick event via dom

    Is there a way to change just the onClick action via the dom or do you have to change the entire element like:

    Code:
    createElement("<a href='#' onClick=\"methodName(" + action + ")\">text</a>");
    Cheers,
    Daf

  • #2
    Senior Coder
    Join Date
    Feb 2003
    Posts
    1,665
    Thanks
    0
    Thanked 27 Times in 25 Posts
    DOM 0…

    Presuming the value of action var has been set prior to this instruction…
    Code:
    obj.onclick = function() { methodName(action) }

  • #3
    New Coder
    Join Date
    Sep 2005
    Posts
    45
    Thanks
    0
    Thanked 0 Times in 0 Posts
    worked a charm, thanks!


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •