我正在使用以下代码
$(document).ready({
if ($('.help-block').text().length > 0) {
setTimeout(function(){$('.help-block').text("");},3000);
}
});
但出现以下错误
Uncaught SyntaxError: Unexpected token (
在下面一行
if ($('.help-block').text().length > 0) {
我无法解决这个问题。需要帮助
最佳答案
问题是因为您向 $(document).ready()
提供对象而不是函数。试试这个:
$(document).ready(function() { // note function() here
if ($('.help-block').text().length > 0) {
setTimeout(function() {
$('.help-block').text(''); // you could use empty() here instead
}, 3000);
}
});
关于jquery - 未捕获的语法错误 jQuery,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43738306/