P粉3279030452023-09-03 00:48:53
Follow your #ifYes
tags. Wrap the input and label with div
, assign it an id
, and then just use document.getElementById('select-end-period').style.display = 'none';
function yesnoCheck() { if (document.getElementById('yesCheck').checked) { document.getElementById('ifYes').style.display = 'block'; document.getElementById('select-end-period').style.display = 'none'; } else { document.getElementById('ifYes').style.display = 'none'; document.getElementById('select-end-period').style.display = 'block'; } }
<form> <input type="radio" onclick="javascript:yesnoCheck();" name="yesno" id="noCheck">选择期间 <br> <br> <input type="radio" onclick="javascript:yesnoCheck();" name="yesno" id="yesCheck">从日期开始的推文数量<br><br> <div id="ifYes" style="display:none"> 期望推文数量 <input type="number" min="1" max="20" id='yes' name='yes'><br> </div> <br> <img src="icon2.png"><label for="date">选择开始日期:</label><br> <input type="datetime-local" id="Test_DatetimeLocal"><br><br> <div id="select-end-period"> <img src="icon2.png"><label for="date">选择结束日期:</label><br> <input type="datetime-local" id="Test_DatetimeLocal"><br><br> </div> <input type="submit" value="提交" class="submit"> </form>