我正在尝试使用<div>
显示id="importLocations"
,当我点击“go”按钮时 - 它一切正常但我想用jquery做,但我无法做到工作:
<script>
function onClickButton(){
alert("Came inside");
document.getElementById('importLocations').style.display ='inline';
}
</script>
<label>Functions/Tools :</label>
<select id ="selFunction" name ="selFunction" class ="DataEntryField">
<option value ="Select">Select</option>
<optgroup label="Import From">
<option value ="1">India</option>
<option value ="2">America</option>
<option value ="3">china</option>
</optgroup>
</select>
<input type="button" value="Go" id="functionBtn" onClick="onClickButton()" class = "input"/>
<div id="importLocations" style="display:none;" class="header">
<span id="locatinCaption">Import Location</span> <span class="close">
<img id="closeLoc" width="15px" height="15px" alt="Close this section" src="/resources/images/crossMark.gif"/></span>
<br/>
<label class="DataEntryLabel"> Search by </label>
<input type="text" id="importLocation" value="select" size="30" readonly="readonly"/>
<input type="text" id="searchTextArea" size="30" class="DataEntryField"/>
<button type="button" id="importLoc" value="importLoc" class="DataEntryButton"/>search</button>
</div>
答案 0 :(得分:3)
在<head>
内,添加:
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>
以这种方式使用:
function onClickButton(){
$('#importLocations').show();
}
或者,不引人注意地:
$(document).ready(function(){
$('#functionBtn').click(function(){
$('#importLocations').show();
});
});
答案 1 :(得分:0)
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>
<script>
$(document).ready(function(){
$('#functionBtn').click(function(){
$('#importLocations').show();
});
});
</script>
将这些脚本标记放在页面的“头部”中。