jquery小知識点

669 ワード

1.radioラジオボタンの値と割り当て
値:
$("input[name=gc][checked]").val();

gcはradioのname値
割り当て:
$("input[name=gc][value=Y]").attr("checked",true);

gcはradioのname値、valueはradioのvalue値
2.select取値と賦値
値:
$("#sz").find("option:selected").val();

szはselectのid
割り当て:
$("#sz").attr("value",rs.sz_id);

  rs.sz_idはselect下optionのvalue値
3.入力ボックス左右のスペースを外す
 
test.replace(/(^\s*)|(\s*$)/g, "")

testは文字列