我有一个带有高级选项的表格。高级选项位于 div(隐藏)中。当“搜索”输入框被键入时,我想使用向下滑动取消隐藏 div。这是代码(部分取自另一个来源:jQuery slideDown with forms):
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"></script>
<script src="http://code.jquery.com/jquery-1.9.1.js"></script>
<script src="http://api.jquery.com/resources/events.js"></script>
<script type="text/javascript">
$("#searched").keypress(function(event) {
if ( event.which == 13 ) {
event.preventDefault();
}
$("#advanced").slideDown();
});
</script>
</head>
<body>
<div id="content">
<form action="mycontrolleraddress" method="post" accept-charset="utf-8" name="search_form" id="search_form">
<input type="text" name="query" value="" placeholder="Search..." id="searched"/><br/>
<div id="advanced" style="display: none;">
From: <input type="text" name="date_from" value="" id="datepicker" onchange="validateDate();" class="datefield" /><br/>
To: <input type="text" name="date_to" value="" id="datepicker2" onchange="validateDate();" class="datefield" /> <br/>
</div>
<input type="submit" name="submit" value="Submit" />
</div>
</body>
</html>