jquery 下拉框改变 事件 动态显示input
2015-12-07 13:09
696 查看
html:
jquery:
//供地类型值发生改变时,为合同编号赋值
$("#landTypeId").change(function(){
$("#addInputId").empty();
if($("#landTypeId").val() !='' ){
var landTypeId=$("#landTypeId option:selected").html();
var value=$("#landTypeId").val();
if(value=='0'){
$("#contractNum").val('济南-02-');
$("#dateId").addClass("hide");
$("#addInputId").append("<input name='contractNum' maxlength='6' style='width:265px;display:inline;' class='form-control required'/>");
}
else{
$("#contractNum").val('济南-01-');
$("#dateId").removeClass("hide");
$("#addInputId").append("<input name='contractNum' maxlength='4' style='width:155px;display:inline;' class='form-control required'/>");
}
}
<form:input path="contractNum" htmlEscape="false" maxlength="100" class="form-control required" style="width:80px;display:inline;"/> <input name="date" id="dateId" type="text" readonly="readonly" maxlength="20" class="form-control hide Wdate" style="width:100px;display:inline;" value="<fmt:formatDate value="<%=new Date()%>" pattern="yyyy"/>" onclick="WdatePicker({dateFmt:'yyyy',isShowClear:false});"/> <span id="addInputId" style="display:inline;">
jquery:
//供地类型值发生改变时,为合同编号赋值
$("#landTypeId").change(function(){
$("#addInputId").empty();
if($("#landTypeId").val() !='' ){
var landTypeId=$("#landTypeId option:selected").html();
var value=$("#landTypeId").val();
if(value=='0'){
$("#contractNum").val('济南-02-');
$("#dateId").addClass("hide");
$("#addInputId").append("<input name='contractNum' maxlength='6' style='width:265px;display:inline;' class='form-control required'/>");
}
else{
$("#contractNum").val('济南-01-');
$("#dateId").removeClass("hide");
$("#addInputId").append("<input name='contractNum' maxlength='4' style='width:155px;display:inline;' class='form-control required'/>");
}
}
相关文章推荐
- jQuery设计思想
- JS与jQuery遍历Table所有单元格内容的方法
- jquery动态添加div
- 多选下拉框 jquery.multiple.select的使用
- jQuery 效果 - 淡入淡出
- Jquery的一些取值
- 颜色动画插件jquery.color.js的使用示例
- jquery思维导图
- jquery实现数字抽奖(版本2)
- jQuery选择器总结
- jQuery选择器全集详解
- jquery中toggleClass方法用于样式切换
- jQuery中this与$(this)的区别
- JQuery实现——黑客帝国代码雨效果
- jquery
- jquery的innerHTML
- Jquery实现广告滚动
- jQuery 文档操作方法(w3school)
- 5 款最新的 jQuery 图片裁剪插件
- jquery 获取select和checkbox的值