• This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn more.

Invoke JS function when "Create Thread" button is clicked?


Well-known member
I'm working on a minor tweak to an add-on and, as part of it, I would like to invoke a javascript function with the "Create Thread" button is clicked.

I've tried going down the path of using jQuery but ran into a bit of a stumbling block because the "Create Thread" buttons don't have ID values assigned to them ("them" because there are two on the page when creating a thread).

My real goal is to change the value of a text box after clicking the "Create Thread" button and before the form post kicks in but to keep it simple I'm starting with just generating a standard JS alert message for testing.

With that it mind... what approach would you take to invoke a JS function when clicking on the "Create Thread" button?

Just to be clear, if you were at http://xenforo.com/community/forums/test-messages.6/create-thread and clicked either of the "Create Thread" buttons, how would you go go about displaying a JS alert message when the button is clicked?


Well-known member
Try this to select the button in jQuery:

$(".thread_create input[type='submit']").click(function(e) {
    // Event handler goes here...