Anybody has any idea why this snippet is NOT working in newest version of Firefox? (working correctly ex. in Chrome).
$("select[name='action']").live('change', function()
{
$(this).closest("form").attr('action', $(this).val());
alert($(this).closest("form").attr('action'));
//$(this).closest("form").submit();
});
Edit It's not working in IE8 too. Weird.
HTML
<form method="post" action="#">
<fieldset>
<select style="width:95px" name="action" class="action">
<option>Select</option>
<option value="/user/account">Preview</option>
<option value="/user/account/edit">Edit</option>
<option value="/user/account/upgrade">Upgrade</option>
</select>
</fieldset>
</form>
It's a naming-conflict, give the select another name.
The form has an attribute "action" and a member "action" (the select itself, because it's name is "action").
The alert should give you in FF an [object HTMLSelectElement]
, form.attr('action')
points here onto the <select/>
instead of the action-attribute of the form, which you like to access.