我想使用父类获取跨度内的数据



我想使用jQuery中的tr类tr1获取在class="select2-selection__rendered"所在的span中写入的内容。谢谢你的帮助!

代码:

<tr class="tr1" id="1">
<td>
<select class="selUser select2-hidden-accessible" name="select[]" tabindex="-1" aria-hidden="true">
<option value="0">----Select Product----</option>
<option value="Haris">Haris</option> 
<option value="Hammad">Hammad</option> 
<option value="Haroon">Haroon</option> 
<option value="Haseeb">Haseeb</option> 
</select>
<span class="select2 select2-container select2-container--default select2-container--below select2-container--focus" dir="ltr" style="width: 300px;">
<span class="selection"><span class="select2-selection select2-selection--single" role="combobox" aria-haspopup="true" aria-expanded="false" tabindex="0" aria-labelledby="select2-select-ht-container">
<span class="select2-selection__rendered" id="select2-select-ht-container" title="Hammad">Hammad</span><span class="select2-selection__arrow" role="presentation"><b role="presentation"></b></span></span></span>
<span class="dropdown-wrapper" aria-hidden="true"></span></span> 
</td>
<td><input class="price price1" type="text" value="0" disabled=""></td>
<td><input class="quantity quantity1" id="1" type="number" value="1"></td>
<td><div id="total1"></div></td>
<td><div style="text-align:center; width:35px;"><button type="button" class="close" id="1"><i class="fas fa-window-close"></i></button></div></td>
</tr>

你的意思是这样的吗?

$('tr.tr1 td span.select2-selection__rendered').text()

甚至像这样?

$('tr.tr1 td span.select2-selection__rendered').html()

最新更新