SitePoint Sponsor

User Tag List

Results 1 to 2 of 2
  1. #1
    SitePoint Guru augathra's Avatar
    Join Date
    Jul 2004
    Location
    united states
    Posts
    826
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    How to put variable in onclick?

    Hello, I have a JS variable I want to write inside of a onclick="" attribute. Could someone help me out?
    Example:
    <script>
    var cool = "hello";
    </script>
    <a href="#" onclick="RunFunction(cool)">Text</a>


    Thanks

  2. #2
    SitePoint Guru augathra's Avatar
    Join Date
    Jul 2004
    Location
    united states
    Posts
    826
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Grrr, I tried this again, and now it's working! GRRR? No idea what I did wrong the first time.


Bookmarks

Posting Permissions

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