gpt4 book ai didi

php - jQuery:单选按钮选择决定要显示哪个 div,具有“checked”属性

转载 作者:行者123 更新时间:2023-11-30 18:34:20 24 4
gpt4 key购买 nike

我有一个表单,其中包含由单选按钮提供的不同选项。我还有一个脚本,它显示具有不同表单输入的不同 div。

这个脚本工作正常,我的问题是我有一个“上一个”链接,用户可以在其中后退一步并编辑已经输入的数据,而且我无法通过已选中 单选按钮的属性。它必须被点击,这是有道理的,因为我的脚本使用了 .click 事件。

但我怎么能这样说:“If $_SESSION[‘unemployed’] == ‘yes’ then echo ‘checked’”并显示正确的选项。

我希望我的解释是正确的,否则请随意提问。
请在此处查看代码 http://jsfiddle.net/GEFMX/1/我的问题是一个或多个复选框是否默认为“已选中”。

我使用的 Javascript 如下所示:

<script type="text/javascript">
$(function() {
$("input[name$='step2_student']").click(function() {
var diffoptions = $(this).val();

$("div.studerende_janej").hide();
$("#studerende" + diffoptions).show();
});

$("input[name$='step2_otheredu']").click(function() {
var diffoptions = $(this).val();

$("div.othereducation_janej").hide();
$("#othereducation" + diffoptions).show();
});

$("input[name$='step2_haveeducation']").click(function() {
var diffoptions = $(this).val();

$("div.haveeducation_janej").hide();
$("#haveeducation" + diffoptions).show();
});
});
</script>

真诚
- 梅斯蒂卡

最佳答案

您可以在页面加载中添加一些代码,以触发所有选中的 radio 的“点击”。即类似的东西:

$(function() {

// .. bind your click events here

$('input[type="radio"]').each(function() {
if($(this).prop('checked')) $(this).click(); // trigger 'click' if checked
});

});

关于php - jQuery:单选按钮选择决定要显示哪个 div,具有“checked”属性,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8729025/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com