| 両方とも前のリビジョン前のリビジョン次のリビジョン | 前のリビジョン |
| study:javascript:jquery:clear-form [2011/04/07 02:51] – [demo] banana | study:javascript:jquery:clear-form [2017/11/28 04:26] (現在) – [code snippet] banana |
|---|
| function clearForm(){ | function clearForm(){ |
| if(confirm('データをクリアにしてよろしいですか?')){ | if(confirm('データをクリアにしてよろしいですか?')){ |
| $("input[type='text'], textarea").not("input[readonly='true'], :hidden, :button, :submit, :reset").val(""); | $("input[type='text'], textarea").not("input[readonly='true'], input[type='hidden'], :button, :submit, :reset").val(""); |
| $("input[type='radio'], input[type='checkbox'], select").removeAttr("checked").removeAttr("selected"); | $("input[type='radio'], input[type='checkbox'], select").removeAttr("checked").removeAttr("selected"); |
| $("select option:first-child").attr("selected", "selected"); | $("select option:first-child").attr("selected", "selected"); // 1.6以前のバージョン |
| | $("select").prop("selectedIndex", "0"); // 1.6以降 |
| } | } |
| } | } |