li > .select2-selection__choice").-6ren">
gpt4 book ai didi

javascript - 如何在 HTML JS 中获取外部文本

转载 作者:行者123 更新时间:2023-12-03 02:55:32 24 4
gpt4 key购买 nike

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

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com