来个jQuery大神,我有个东西不会弄,帮下忙呗. jqueryjavascript 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 做了个演示代码<input type="text" id="address" value="请输入邮箱地址" /><br><input type="text" id="password" value="请输入邮箱密码" /><br><input type="button" value="登录" /><br><br><br><input type="button" id="btn1" value="使单选下拉框的*选择3号*被选中" /><input type="button" id="btn2" value="使多选下拉框选中的*选择2号*和*选择4号*被选中" /><br><input type="button" id="btn3" value="使多选框的*多选2*和*多选4*被选中" /><input type="button" id="btn4" value="使单选框的*单选2*被选中" /><br><input type="button" id="btn5" value="打印已经被选中的值" /><br><br/><select id="single"> <option>选择1号</option> <option>选择2号</option> <option>选择3号</option></select><select id="multiple" multiple="multiple" style="height:120px;"> <option selected="selected">选择1号</option> <option>选择2号</option> <option>选择3号</option> <option>选择4号</option> <option selected="selected">选择5号</option></select><br/><br/><input type="checkbox" name="c" value="check1" /> 多选1<input type="checkbox" name="c" value="check2" /> 多选2<input type="checkbox" name="c" value="check3" /> 多选3<input type="checkbox" name="c" value="check4" /> 多选4<br/><input type="radio" name="r" value="radio1" /> 单选1<input type="radio" name="r" value="radio2" /> 单选2<input type="radio" name="r" value="radio3" /> 单选3$(document).ready(function(){ toggleInput("#address", "请输入邮箱地址"); toggleInput("#password", "请输入邮箱密码"); $("#btn1").click(function(){ setSelection("#single", "选择3号"); }); $("#btn2").click(function(){ setSelection("#multiple", ["选择2号", "选择4号"]); }); $("#btn3").click(function(){ setSelection("input[name='c']", ["check2", "check4"]); }); $("#btn4").click(function(){ setChecked("input[name='r'][value='radio2']", true); }); $("#btn5").click(function(){ $("input:text, option:selected, input:checked").map(function(){ alert($(this).val()); }) }); });function toggleInput(el, msg){ $(el).focus(function(){ if($(this).val() == msg){ $(this).val(""); } }).blur(function(){ if($(this).val() == ""){ $(this).val(msg); } });}function setSelection(el, selected){ $(el).val(selected);}function setChecked(el, checked){ $(el).prop("checked", checked);} B/S定时刷新,导致html控件数据清空 请教正则表达式: clipboardData对象应怎么用 请高手帮助啊 file输入框的问题。。。! 求一断JS代码,功能见内容 怎么让一个iframe在提交数据后隐藏! 这几个函数有点不明白啊,求助,一问15分 取textarea中光标所在行的文本? 请高手加盟,有java编程经验,特别对javascript精通。 如何用Javascript控制打印机走纸?(说情见内) 用JQuery clone 拷贝了一个tr后,怎么把里面的所有元素的id自动加上"_1" java如何解析javascript
<input type="text" id="password" value="请输入邮箱密码" /><br>
<input type="button" value="登录" /><br>
<br><br>
<input type="button" id="btn1" value="使单选下拉框的*选择3号*被选中" />
<input type="button" id="btn2" value="使多选下拉框选中的*选择2号*和*选择4号*被选中" /><br>
<input type="button" id="btn3" value="使多选框的*多选2*和*多选4*被选中" />
<input type="button" id="btn4" value="使单选框的*单选2*被选中" /><br>
<input type="button" id="btn5" value="打印已经被选中的值" /><br>
<br/>
<select id="single">
<option>选择1号</option>
<option>选择2号</option>
<option>选择3号</option>
</select><select id="multiple" multiple="multiple" style="height:120px;">
<option selected="selected">选择1号</option>
<option>选择2号</option>
<option>选择3号</option>
<option>选择4号</option>
<option selected="selected">选择5号</option>
</select>
<br/><br/>
<input type="checkbox" name="c" value="check1" /> 多选1
<input type="checkbox" name="c" value="check2" /> 多选2
<input type="checkbox" name="c" value="check3" /> 多选3
<input type="checkbox" name="c" value="check4" /> 多选4
<br/>
<input type="radio" name="r" value="radio1" /> 单选1
<input type="radio" name="r" value="radio2" /> 单选2
<input type="radio" name="r" value="radio3" /> 单选3
$(document).ready(function(){
toggleInput("#address", "请输入邮箱地址");
toggleInput("#password", "请输入邮箱密码");
$("#btn1").click(function(){
setSelection("#single", "选择3号");
});
$("#btn2").click(function(){
setSelection("#multiple", ["选择2号", "选择4号"]);
});
$("#btn3").click(function(){
setSelection("input[name='c']", ["check2", "check4"]);
});
$("#btn4").click(function(){
setChecked("input[name='r'][value='radio2']", true);
});
$("#btn5").click(function(){
$("input:text, option:selected, input:checked").map(function(){
alert($(this).val());
})
});
});function toggleInput(el, msg){
$(el).focus(function(){
if($(this).val() == msg){
$(this).val("");
}
}).blur(function(){
if($(this).val() == ""){
$(this).val(msg);
}
});
}function setSelection(el, selected){
$(el).val(selected);
}function setChecked(el, checked){
$(el).prop("checked", checked);
}