为什么 jquery find 在我的选择选项中不起作用?

问题描述 投票:0回答:0

嗨,我正在尝试将类添加到我从表行中获取的基于选择选项元素的值。我的 js 无法正常工作,它会抛出语法错误,无法识别的表达式。我的错误是什么?

HTML:

<td class="doctor">[email protected]</td>
<select class="select floating" id="a_doctor" name="doctor"> 
 <option> -- Select -- </option>
 <option value="[email protected]">[email protected]</option>
</select>

Javascript:

 $(document).on('click', '.appointment-edit', function()
 {
    var _this = $(this).parents('tr');
    var a_doctor = (_this.find(".doctor").text());
    $("#a_doctor").find("option[value='" + a_doctor + "']").addClass("selected");
 });
javascript jquery
© www.soinside.com 2019 - 2024. All rights reserved.