1。文本框的改变事件,可使用propertychange,例如:
$("#txtDataDate").bind("propertychange",function(){
});
});
2。获取被选中RadioButton 的值
var radio_value = $("input[@type=radio][checked]").val();
3。下拉列表的改变事件,以及获得选中选项的值
$("#下拉列表").change(function() {
//获得选中项的value值
var select = $(this).val();
}).change();
//获得选中项的value值
var select = $(this).val();
var checkText=$("#select_id").find("option:selected").text(); //获取Select选择的Text
}).change();
4。获取下拉列表DropDownList选中的值
var ddl = $("#ddlDiaryType option:selected").text();//下拉别表
5。Jquery绑定同一事件时,如要只执行一个事件,需要用 $("#txt").unbind();方法卸载事件,例如:
代码
$("#ddlType").change(function () {
var now = new Date();
var ADateNow = now.getYear() + "-" + (now.getMonth() + 1);
var select = $(this).val();
$("#txtStartTime").unbind("focus");
$("#txtEndTime").unbind("focus");
if (select == "月") {
var ADate = ADateNow;
$("#txtStartTime").focus(function () { WdatePicker({ isShowClear: false, readOnly: true, skin: 'whyGreen', dateFmt: 'yyyy-MM' }); }).val(ADate);
$("#txtEndTime").focus(function () { WdatePicker({ isShowClear: false, readOnly: true, skin: 'whyGreen', dateFmt: 'yyyy-MM' }); }).val(ADate);
}
else {
ADate = ADateNow + "-" + now.getDate();
$("#txtStartTime").focus(function () { WdatePicker({ isShowClear: false, readOnly: true, skin: 'whyGreen', dateFmt: 'yyyy-MM-dd' }); }).val(ADate);
$("#txtEndTime").focus(function () { WdatePicker({ isShowClear: false, readOnly: true, skin: 'whyGreen', dateFmt: 'yyyy-MM-dd' }); }).val(ADate);
}
}).change();
var now = new Date();
var ADateNow = now.getYear() + "-" + (now.getMonth() + 1);
var select = $(this).val();
$("#txtStartTime").unbind("focus");
$("#txtEndTime").unbind("focus");
if (select == "月") {
var ADate = ADateNow;
$("#txtStartTime").focus(function () { WdatePicker({ isShowClear: false, readOnly: true, skin: 'whyGreen', dateFmt: 'yyyy-MM' }); }).val(ADate);
$("#txtEndTime").focus(function () { WdatePicker({ isShowClear: false, readOnly: true, skin: 'whyGreen', dateFmt: 'yyyy-MM' }); }).val(ADate);
}
else {
ADate = ADateNow + "-" + now.getDate();
$("#txtStartTime").focus(function () { WdatePicker({ isShowClear: false, readOnly: true, skin: 'whyGreen', dateFmt: 'yyyy-MM-dd' }); }).val(ADate);
$("#txtEndTime").focus(function () { WdatePicker({ isShowClear: false, readOnly: true, skin: 'whyGreen', dateFmt: 'yyyy-MM-dd' }); }).val(ADate);
}
}).change();