[英]radio button show divs on the based on its value
我有一個基於mysql表中的id的單選按鈕列表。
每當收音機上的時鍾時,它就會顯示div詳細信息,例如
單選按鈕
<input name="value" type="radio" value="facebook" id="facebook"/> facebook
<input name="value" type="radio" value="google_plus" id="google_plus" /> Google plus
<input name="value" type="radio" value="orkut" id="orkut" /> orkut
股利
<div id="facebook" style="display:none;">
facebook is one of the most popular social networking website
</div>
<div id="google" style="display:none;">
google plus is the new social network
</div>
<div id="orkut" style="display:none;">
Orkut is a socila networking website powered by google
</div>
當選擇單選按鈕時,我需要在單選按鈕的base value=""
值上顯示div。 事實是,無線電數字和值將基於mysql數據
有沒有選擇來顯示jQuery中的div?
如果你知道幫我請
從看起來像是在問您想知道如何通過jquery顯示div?
.show()方法
或.css()方法示例:$('nameOfYourDiv')。css('display','block');
$('input[name="value"]').change(function(){
var id = $(this).val();
$('#' + id).show();
});
希望這段代碼對您有幫助。 這是我為您的問題尋找解決方案的嘗試:)
$('input:radio').click(function(){
var idVal = $(this).val();
$('div').hide();
$('div[id='+idVal+']').show()
});
請在此處找到工作示例: http : //jsfiddle.net/u3AbT/3/
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.