我有一个div点击文本标题崩溃.我想相应地将标题从"+过滤器"更改为" - 过滤器"(当div折叠或展开时)
我如何使用jQuery执行此操作:
if (headerDiv.text() starts with "+")
replace "+" with "-"
else
replace "-" with "+"
Run Code Online (Sandbox Code Playgroud)
?
jua*_*uan 13
没关系,我想通了
if ($(header).text().trim().charAt(0) == "+")
$(header).text($(header).text().replace("+", "-"));
else
$(header).text($(header).text().replace("-", "+"));
Run Code Online (Sandbox Code Playgroud)
如果这不是正确的方法,我会很高兴