[英]Display a pop-up on radio button click
請讓我知道如何使用JQuery單擊單選按鈕來打開彈出窗口。 目前我使用Spring MVC和JSTL為單選按鈕使用以下代碼
<label class = "">
<form:radiobutton path = "" value = "" onchange= ""/>
<label class = "" style = ""> <spring:message code ="" /></label>
</label>
非常感謝
我假設您是指pop-up
一個新窗口?
當單選按鈕的狀態更改時,以下代碼將使用URL打開一個新窗口。 如果願意,可以使用click
。
$("#pop").change(function() {
window.open("http://www.google.com");
});
<input type="radio" id="pop" value="yes">
我希望這能解決您的問題。
onchange= "window.open("http://www.stackoverflow.com",width=200,height=100); "/>
EDIT1:刪除hide
類可以解決問題。
jQuery的:
$(document).ready(function () {
$('input[type="radio"]').click(function () {
$('#r').removeClass("hide");
});
});
HTML:
<input type='radio'>SO
<div id="r" selectOption="#" class="modal hide" tabindex="-1" role="dialog" style=" background-color:#ccc; height: 100px;width: 350px"></div>
編輯2:
如果檢查我的html代碼,將看到div的ID為“ r”(唯一選擇器),而類名“ hide”則阻止div的顯示。 因此div是隱藏的。
單擊單選按鈕時,使用removeClass 刪除“隱藏”類,使div可見。
檢查這個JSFiddle
希望你能理解。
你的意思是這樣嗎? 點擊這里
的HTML
<input type='radio' id='myRadio'>Radio button
jQuery查詢
$(document).ready(function()
{
$('#myRadio').click(function()
{
alert("Clicked");
});
});
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.