<ul class="select2-selection__rendered">
<li class="select2-selection__choice" title="List"><span class="select2-selection__choice__remove" role="presentation">×</span>**List**</li>
<li class="select2-search select2-search--inline">
<input class="select2-search__field" type="search" tabindex="0" autocomplete="off" autocorrect="off" autocapitalize="off" spellcheck="false" role="textbox" aria-autocomplete="list" placeholder="" style="width: 0.75em;">
</li>
</ul>
这就是代码..
我想获取我加粗的文本“List”。
alert( $("ul > li > .select2-selection__choice").text() );
仍然无法获取文本。 谢谢
最佳答案
您可以使用以下代码,
alert(e.params.data.text);
这将为您提供您要求的答案。这将显示最后一个未选择的值。
关于javascript - 如何在 HTML JS 中获取外部文本,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47645152/