Search code examples
javascriptjquerygreasemonkeyuserscripts

Userscript: run code before submit


Currently making a user script. Issue I'm having is that when this one submit button is click, my code is not run. Any help?

$('#quick_reply_submit, input[value="Post Reply"]').click(function()
{
    clearCookie();
});

In clearCookie(), I'm just deleting a cookie. Alert()'ing a message works fine. I've tried return false but that doesn't work, either.

--

The HTML:

<input type="submit" class="button" name="submit" value="Post Reply" tabindex="3" accesskey="s">

As I say, there's nothing wrong with the selector. A message is being alert()'ed, but no code after.

--

EDIT: Fixed. See my answer.


Solution

  • This was my fault. Nothing to do with the selectors or the code above.

    I was removing a cookie when the button was clicked, however I was re-saving the cookie on blur which was the problem.