【发布时间】:2016-08-29 23:12:54
【问题描述】:
我需要检测跨度中的文本是否以字母“x”开头并运行一个函数。我读到我可以用字符串中的“^”来做到这一点 - 但在检查文本时遇到了麻烦......
<span>xfoo</span>
if ($('span:contains(^"x")').length > 0) {
alert ('there is text on this page starts with x');
}
我还可以检查输入字段的值...
【问题讨论】:
-
对于初学者来说,您的跨度“以”空格开头...
标签: javascript jquery html contains startswith