Dan06
09-04-2009, 08:30 PM
My jQuery if/else if statement is finding both conditions to be true - even if it is impossible for both to be true - and I can't figure out why.
I have a jQuery post that returns and inserts 1 of 2 forms into the page html. After inserting the form, a simple if/else if statement binds to the submit event a particular function based on which form is inserted. Below is the if/else if statement, anyone see what is wrong?
if ($("#nameSearch")) {
$("#showNames").click(function() { showChoices(sel); });
} else if ($("#addressSearch")) {
$("#showAddresses").click(function() { showChoices(sel); });
}
I have a jQuery post that returns and inserts 1 of 2 forms into the page html. After inserting the form, a simple if/else if statement binds to the submit event a particular function based on which form is inserted. Below is the if/else if statement, anyone see what is wrong?
if ($("#nameSearch")) {
$("#showNames").click(function() { showChoices(sel); });
} else if ($("#addressSearch")) {
$("#showAddresses").click(function() { showChoices(sel); });
}