how to fire javascript code when button is submit pressed

Discussion in 'Programming' started by lew1s666, Sep 26, 2014.

  1. #1
    i have a wordpress contact form with contact form 7 and need to fire javascript when submit button is pressed. how can i do this? what to add in footer ?
     
    lew1s666, Sep 26, 2014 IP
  2. PoPSiCLe

    PoPSiCLe Illustrious Member

    Messages:
    4,623
    Likes Received:
    725
    Best Answers:
    152
    Trophy Points:
    470
    #2
    Use an ID on the submit, and trigger the javascript when that is clicked? If you're using jQuery (most libraries are built in to Wordpress, and can be called on), it would be something like:
    
    $('#submit_button_id').click(function() {
    // do stuff here
    });
    
    Code (markup):
    That assumes you have jQuery loaded
     
    PoPSiCLe, Sep 29, 2014 IP