I have a problem with an if statement but I can’t get the code right.
I have multiple divs on a page with form elements. I have a reset button that clears all input fields via .val(" ") but I need to exclude input[type=button] somehow.
I don’t have much knowledge around if statements and the formatting is definitely going wrong somewhere.
<!-- Reset only current div -->
$('.reset_form').live('click', function() {
$(this).parents("div.menu_creation_form").find("input").val('');
if () {
$(this).parents("div.menu_creation_form").find("input[type=button]").val();
}
else() {
// do nothing
}
});
You can only select text inputs using the same kind of attribute selector:
However, this won’t work if you don’t explicitly set the
typeattribute equal totext. If you leave the type attribute out, the default value will be used and a textbox will be rendered, but it won’t be found by this select. To get around this, you can use the:textselector:The latter method is a little slower though, I think.