Question

The following code works perfectly on Chrome, Safari and Opera but on Mozilla Firefox.

$("#first").click(function () {
    event.preventDefault();
    $("#second").click();
    return false;
});
<form action="http://jsfiddle.net">
    <input type="submit" value="Go to Bing" id="first">
</form>

<form action="http://example.com">
    <input type="submit" value="Go to adams" id="second">
</form>

Fiddle: http://jsfiddle.net/5GRVb/

[Resolved]: Thanks @ C-lin

Was it helpful?

Solution

You missed to pass the parameter event within the function:

$("#first").click(function(event){
\\    ---------     here    ^^

OTHER TIPS

No need to use event.preventDefault() together with the return false. This will work.

$("#first").click(function(){
    $("#second").click(); 
    return false;
});
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top