gpt4 book ai didi

jquery - 在 jQuery 中计算字母/字符

转载 作者:行者123 更新时间:2023-12-01 06:35:22 24 4
gpt4 key购买 nike

我在网上搜索并查看了有关如何计算字符数的 API 文档,我目前正在使用这个:$('.test').val().length;

但是,它根本不起作用。

我的 div 看起来像这样:<div class="test">Count These Letters</div>

我预计$('.test').val().length;返回19 ,而是返回 1 ...我使用了错误的功能吗?

最佳答案

对于文本,您需要 .text(),如下所示:

 $('.test').text().length

关于jquery - 在 jQuery 中计算字母/字符,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17748605/

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