有没有办法根据您在 html 选择选项下拉列表中选择的选项,使用 Javascript 将样式附加到现有类?
例如,在下表中,当从选项框中选择该数字时,我希望相应的数字变为粗体或突出显示。
非常感谢!
<h2>Finder</h2>
<div class="step1">
<p>Show category:</p>
</div>
<select type="search" class="select-table-filter" data-table="order-table" id="searchInput">
<option value="">All</option>
<option value="1">1</option>
<option value="2">2</option>
<option value="3">3</option>
</select>
<input type="search" class="light-table-filter" data-table="order-table" placeholder="Search ..." />
<table class="order-table" id="myTable">
<thead>
<tr class="header">
<th>Category</th>
<th>Name</th>
<th>Last Name</th>
<th>Phone</th>
<th>Email</th>
</tr>
</thead>
<tbody>
<tr>
<td>1</td>
<td>Taylor</td>
<td>Swift</td>
<td>1234 5678</td>
<td>taytay@gmail.com</td>
</tr>
<tr>
<td>2, 3</td>
<td>John</td>
<td>Smith</td>
<td>1234 5678</td>
<td>johnnyboy@gmail.com</td>
</tr>
<tr>
<td>3</td>
<td>Jane</td>
<td>Doh</td>
<td>1234 5678</td>
<td>dohnut@gmail.com</td>
</tr>
<tr>
<td>3, 4</td>
<td>Taylor</td>
<td>Doh</td>
<td>1234 5678</td>
<td>td@gmail.com</td>
</tr>
</tbody>
</table>