0
首先,我在这里搜索过去的一小时,看看我发布之前是否找到了我的问题的答案,但您是我的最后希望!我发现一段代码几乎可以按我的需要工作,但并不完全。jquery - 显示基于单选按钮检查div?
- 我需要摆脱淡入和淡出。
- 我需要脚本来检查onload哪个单选按钮被选中并显示正确的div。
这里是我的代码:
<input type="radio" name="d_method" class="c_email"/>Email
<input name="d_method" type="radio" class="c_collection"/>Colletion
<input name="d_method" type="radio" class="c_post"/>Post
<div id="c_email" style="display:none;">
email textbox
</div>
<div id="c_collection" style="display:none;">
collection textbox
</div>
<div id="c_post" style="display:none;">
post textbox
</div>
这里是jQuery的:
$(':radio').change(function() {
var itemSelector = '#' + $(this).attr('class');
$('div').stop().fadeOut(function() {
$(itemSelector).fadeIn();
});
});
什么不能在你的脚本中工作 –
单选按钮应该保存一个值...比你使用'.prop()'... bla bla bla等等。 –
可能的重复http://stackoverflow.com/q/8121577/448232和http://stackoverflow.com/a/4108027/448232。 –