jquery - Restoring selects after submit doesn't work -
this how trying (no firebug errors) restore each select of form first option value
/* $(this) form */ $(this).find('input[type="text"],textarea').val(''); /* works */ $(this).find("select").each(function(){ $(this).val($(this,"option:first").val()); /* doesnt */ }); what doing wroing?
-edit-
just found out.. works, why not comma?
$(this).val($(this).find("option:first").val());
just try this:
$(this).find("select").change(); this automatically set first option value default.
if use code need:
$(this).find("select").each(function(){ $(this).val($("option:first", ).val()); /* doesnt */ ^--- places here }); your $(this, "option:first") not worked because code searching select within option, should search option within search.
one format of jquery selector is
$(target, context);
Comments
Post a Comment