所以我通过实现类似的复选框来控制使用CSS的事件:
.box {
display: none;
}
#step-1a:checked ~ .box {
display: block;
}Run Code Online (Sandbox Code Playgroud)
<input name="step1-check" id="step-1a" type="checkbox">
<input name="step1-radio" id="step-1b" type="radio">
<input name="step1-radio" id="step-1c" type="radio">
<div class="box">Hello world!</div>Run Code Online (Sandbox Code Playgroud)
CSS用于引导用户完成具有多个步骤的表单.我遇到的问题是,我希望表单要求选中复选框并选中其中一个单选按钮.有没有办法在我的样式表中加入逻辑'&&'来强制执行此操作?
我正在尝试使用JQuery .prop()函数向元素添加自定义属性,但无济于事.这是我尝试过的:
var header = $(document.getElementById("header-main"));
if (header.prop('error')) {
//do something
}
else {
$('#header-main').prop('error', true);
header.prop('error', true);
//neither of these change the element
header.html('Changes some text'); //.html() actually seems to work.
}
Run Code Online (Sandbox Code Playgroud)
自从我阅读StackOverflow上的文档和一些帖子后,我感到非常困惑,但我似乎无法弄清楚这个问题.
我正在使用JQuery版本3.3.1来获得它的价值