jQuery的如何從ID在JavaScript中獲得複選框值
$(document).ready(function(){
$("#cityshow").click(function(){
$("#citybox").toggle();
});
$('#citybox input[type=radio]').click(function(){
var buttonValue = $(this).val();
$("#citybox").toggle();
$('#cityshow').html(buttonValue);
});
});
HTML
<form action="search.php" name="search" method="get" id="search">
<input type="hidden" value="" id="cityshow">
<div id="cityshow" class="citybox">Sikar</div>
<div id="citybox" class="citycollection">
<div style="height:0px; border-bottom:1px solid #333; width:62.5%; margin:0px; float:right "></div>
<div style="width:100%; padding:20px 15px;">
<ul>
<li><input id="Neem" type="radio" name="sikar" value="Neem Ka Thana"> <label for="Neem">Neema Ka Thana</label></li>
<li><input id="shrimado" type="radio" name="sikar" value="Shri Madhopur"> <label for="shrimado">Shri Madhopur</label></li>
<li><input id="danta" type="radio" name="sikar" value="Danta Ramgarh"> <label for="danta">Danta Ramgarh</label></li>
<li><input id="sikar" type="radio" name="sikar" value="Sikar"> <label for="sikar">Sikar</label></li>
<li><input id="laxmangarh" type="radio" name="sikar" value="Laxmangarh"> <label for="laxmangarh">Laxmangarh</label></li>
<li><input id="fatehpur" type="radio" name="sikar" value="Fatehpur"> <label for="fatehpur">Fatehpur</label></li>
</ul>
</div>
</div>
<input type="text" name="query" id="zipsearch" placeholder="Search By Keywords" required/>
</form>
如何從id
得到的值在JavaScript/jQuery的?
有一個複選框?我可以看到'type =「hidden」'的'input'和'type =「radio」'的其他''。 –