一个previous stackoverflow question将此作为其解决方案的一部分:
$.text([this])
我以前从未见过这种语法。完整的声明是:
return $.text([this]).indexOf(myInput) == 0
所以我认为 $(this).text() 无法使用。
问:文档中哪里提到了 $.text([this])?
最佳答案
当您不需要 $(this)
创建的 jQuery 对象时,使用 $.text([this])
会更有效。它们做同样的事情,只是不需要一路创建 jQuery 对象。
Q: Where is $.text([this]) mentioned in any of the documentation?
这不是据我所知,you're calling jQuery.text
(在当前版本中)是 just an alias for Sizzle.getText
.
关于jquery - 何时使用 $(this).text() 以及何时使用 $.text([this]),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3857096/