SitePoint Sponsor

User Tag List

Results 1 to 2 of 2
  1. #1
    SitePoint Addict
    Join Date
    Aug 2004
    Location
    vi
    Posts
    207
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Thumbs up How to wrap a button click to initiate function

    I ok with jQquery, I have been trying for hours on how to wrap a button click function to this.

    There is a onclick function on button called 'SendTransferAction', but still need to wrap it in the specific button only called button-2.

    Code:
               function SendTransferAction(){
                     jQuery("#response").validate({
                        expression: "if (VAL) return true; else return false;",
                        message: "Please enter correct Capthcha Code"
                     });	
               }

  2. #2
    Unobtrusively zen silver trophybronze trophy
    paul_wilkins's Avatar
    Join Date
    Jan 2007
    Location
    Christchurch, New Zealand
    Posts
    14,526
    Mentioned
    83 Post(s)
    Tagged
    3 Thread(s)
    Quote Originally Posted by danjapro View Post
    but still need to wrap it in the specific button only called button-2.
    The normal way to do that, is to give the button a unique identifier and to make use of that for the purpose of attaching the event to the button.

    HTML Code:
    <button id="button-2">Press my button!</button>
    and with jQuery, you would use this to attach a function to the click event of that button:

    Code javascript:
    $('#button-2').on('click', SendTransferAction);

    Note: normally function names should start as lowercase, because any functions starting as uppercase are normally seen as being a function constructor, such as new Person()
    Programming Group Advisor
    Reference: JavaScript, Quirksmode Validate: HTML Validation, JSLint
    Car is to Carpet as Java is to JavaScript


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
  •