[英]dynamic expandable form on input text field change
I want to build a expandable form when ever the someone enter text into input field. 每当有人在输入字段中输入文本时,我都想构建一个可扩展的表单。 Example user fills the location a form expands below the input fields which asks for check-in/checkout dates.
示例用户填写表格在输入字段下方扩展的位置,该字段要求输入入住/退房日期。
or like in gmail when you enter the search string and click on the arrow it opens the advanced search form. 或类似gmail,当您输入搜索字符串并单击箭头时,它会打开高级搜索表单。 I have attached a screen shot on the same.
我已经附上了相同的屏幕截图。
Thanks in advance for the help. 先谢谢您的帮助。
HTML: HTML:
<input id="geocomplete" style="width:200px;" type="text" placeholder="Type in an address" size="90" autocomplete="on">
<div id="checkInOutDiv" class="hiddenDiv">
<input id="checkInDate" type="text" />
<input id="checkOutDate" type="text" />
</div>
</form>
CSS: CSS:
.hiddenDiv {
display:none;
}
JavaScript: JavaScript:
$(document).ready(function(){
var defaultAddrText = $("#geocomplete").attr("placeholder");
$("#geocomplete").keydown(function(){//could be 'onchange' instead
var addr = $(this).val();
if( addr != '' && addr != defaultAddrText ){
$("#checkInOutDiv").removeClass("hiddenDiv");
}else{
$("#checkInOutDiv").addClass("hiddenDiv");
}
});
});
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.