我正在使用this method将默认值传递到联系表单 7 选择字段。它工作正常,但我真的需要它与 radio 领域一起工作。
我尝试将 jquery 更改为:
jQuery(document).ready(function(){
// get contents of hidden input; store in variable
var val = jQuery("span.hiddendefault input").val();
// set the "selected" attribute for option with value equal to variable
jQuery('radio#style-one option[value=' + val + ']').attr('checked', 'checked');
});
并联系表格 7 至:
[radio radio-525 id:style-one class:test-class "one" "two" "three" "four"]
但单选按钮未按要求进行检查。请问有人有什么想法吗?
[编辑]表单生成的 html:
<span class="wpcf7-form-control-wrap radio-525">
<span id="style-one" class="wpcf7-form-control wpcf7-radio test-class">
<span class="wpcf7-list-item">
<input type="radio" name="radio-525" value="one" />
<span class="wpcf7-list-item-label">one</span>
</span>
<span class="wpcf7-list-item">
<input type="radio" name="radio-525" value="two" />
<span class="wpcf7-list-item-label">two</span>
</span>
<span class="wpcf7-list-item">
<input type="radio" name="radio-525" value="three" />
<span class="wpcf7-list-item-label">three</span>
</span>
<span class="wpcf7-list-item">
<input type="radio" name="radio-525" value="four" />
<span class="wpcf7-list-item-label">four</span>
</span>
</span>
</span>
<span class="wpcf7-form-control-wrap hiddendefault">
<input type="hidden" name="hiddendefault" value="three" />
</span>
最佳答案
您只需为所选值“option2”添加default:2
[radio subcription default:2 "option1" "option2" "option3"]
关于jquery - 联系表 7 和默认单选值,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13636966/