【发布时间】:2012-03-07 06:17:27
【问题描述】:
我的表单中有 4 个 jquery 单选按钮,类似这样
<form:radiobutton path="lcmoption" name ="lcmoptions" id ="lock" value="lock" checked="checked"/>
<fmt:message key="lcm.form.options.lock" />
<form:radiobutton path="lcmoption" name ="lcmoptions" id="unlock" value= "unlock"/>
<fmt:message key="lcm.form.options.unlock" />
<form:radiobutton path="lcmoption" name ="lcmoptions" id="terminate" value="terminate" />
<fmt:message key="lcm.form.options.terminate" />
<form:radiobutton path="lcmoption" name ="lcmoptions" id="wipe" value="wipe" />
<fmt:message key="lcm.form.options.wipe" />
<form:radiobutton path="lcmoption" name ="lcmoptions" id="other" value="other" />
<fmt:message key="lcm.form.options.other" />
onclick 前四个单选按钮我正在使用 AJAX 调用动态加载选择框。当用户单击最后一个选项时,即other,我需要隐藏文本框并显示文本区域。
我尝试使用:
$("input:radio[name=lcmoption]").click(function() {
if(type=="other")
{
$([name="reasonsList"]).css("display",none");
$([name="otherreasonsList"]).css("display", "block");
}
else
{
// AJAX CALL to load dropdown (for other options)
}
}
但这不起作用。我也试过:
$([name="reasonsList"]).hide();
$([name="otherreasonsList"]).show();
这会显示下拉列表和文本区域。谁能帮我隐藏 reasonsList div 并显示具有 other 值的单选按钮的 otherreasonsList div onclick?
【问题讨论】:
-
您是否正确粘贴了代码?不应该是
$("input:radio[name=lcmoptions]"),即名称属性应该与lcmoptions而不是lcmoption匹配。请也粘贴您的 AJAX 代码。 -
那个标记是用什么写的? Java 春天?
标签: javascript jquery