简体   繁体   English

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

[英]I want to fetch the data inside the span using the parent class

I want to fetch what is written inside the span where class="select2-selection__rendered" using the tr class tr1 in jQuery.我想使用 jQuery 中的 tr class tr1来获取class="select2-selection__rendered"范围内写入的内容。 Thanks for helping!感谢您的帮助!

Code:代码:

<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>

you mean something like this?你的意思是这样的?

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

or even like this?甚至像这样?

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM