【问题标题】:How to change class name to my selection in html dropdown?如何在 html 下拉列表中将类名更改为我的选择?
【发布时间】:2018-09-17 21:31:44
【问题描述】:

我有这些输入字段可以满足我的需要

<div class="tab" data-tab-name="height">Fridge Height:
    <input class="" type="checkbox" oninput="this.className = '65-66'">65 to 66 Inches
    <input class="" type="checkbox" oninput="this.className = '67-68'">67 to 68 Inches
</div>

现在我怎样才能在下面的下拉菜单中实现相同的功能?

<select class="">
    <option value="15">15 Inches</option>
    <option value="16">16 Inches</option>
    <option value="17">17 Inches</option>
</select>

我想将选择类更改为我从下拉列表中选择的选项

【问题讨论】:

标签: javascript jquery html


【解决方案1】:

回答:&lt;select onchange="this.className = this.value"&gt;

感谢 Taplar 的回答。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-07-08
    • 2018-02-17
    • 1970-01-01
    相关资源
    最近更新 更多