如果没有满足某些功能,则执行一个功能

时间:2014-10-19 09:00:31

标签: jquery

if ($(this).text != "END") {next()};

这不起作用。如果next()text,则会执行END功能。

 if (!$(this).text == "END") {next()};

这有效,但这与接受的答案here

相反

那么,这样做的正确方法是什么?

3 个答案:

答案 0 :(得分:2)

使用$(this).text()代替$(this).text。它将返回标记的内部文本。否则,您正在将函数与文本进行比较。

答案 1 :(得分:1)

我认为你使用它错了.. jquery函数text();

试试这个。

if ($(this).text() != "END") {next()}; //note the parentheses

答案 2 :(得分:1)

你发表的帖子here一切都很顺利。你也可以像下面那样关注它:

if ($(this).text() != "END") {next()}; // Or
if (!($(this).text() == "END")) {next()};