不知道为什么,我好像想不通。
我的 html 中有一些单选按钮可以切换类别:
<input type="radio" name="main-categories" id="_1234" value="1234" /> // All
<input type="radio" name="main-categories" id="_2345" value="2345" /> // Certain category
<input type="radio" name="main-categories" id="_3456" value="3456" /> // Certain category
<input type="radio" name="main-categories" id="_4567" value="4567" /> // Certain category
用户可以选择任何他/她想要的,但是当某个事件触发时,我想设置 1234
为设置选中单选按钮,因为这是默认的选中单选按钮。
我已经尝试过这样的版本(有和没有 jQuery) :
document.getElementById('#_1234').checked = true;
但它似乎没有更新。我需要它可见的更新,以便用户可以看到它。 有人能帮忙吗?
编辑: 我只是累了,忽略了 #
,谢谢你指出来,那个和 $.prop()
。