Solution 1 :

id selector should be unique. you can change id selector to class selector

<input class="submit"  type="submit"  value= "FormA" />

<input class="submit"  type="submit"  value= "FormB" />

$(function () {
   $(".submit").on('click', function () {
     $("#redirect").show();
   });
});

Solution 2 :

You have 2 elements with same id submit, ids should be unique

However this only works when formA is submitted.

$("#submit") will return only the first submit button

Either use different ids for each form or target will a class selector.

Try something like this

<input id="submitA"  type="submit"  value= "FormA" />    
<input id="submitB"  type="submit"  value= "FormB" />

$(function () {
        $("#submitA, #submitB").on('click', function () {
            $("#redirect").show();
        });
    });

Problem :

I have 2 forms : FormA and FormB

<input id="submit"  type="submit"  value= "FormA" />

<input id="submit"  type="submit"  value= "FormB" />

when either one of the form is submitted, I want this button to appear on screen:

Click button

I tried using jquery. here is the code:

$(function () {
        $("#submit").on('click', function () {
            $("#redirect").show();
        });
    });

However this only works when formA is submitted.
Am I missing something?
How can I make it work for both formA and formB
Help would be greatly appreciated
Good day people.

Comments

Comment posted by jQuery – Selector for duplicate ID’s

Does this answer your question?

By

Leave a Reply

Your email address will not be published. Required fields are marked *