我正在查看 yensdesigns 上的一些代码。 ,并在此函数中检查以确保表单字段完整。所有的 & 符号是怎么回事?这重要吗?我是新手/爱好者,不太明白他用它做什么?
//check if all fields are filled
function checkForm(){
if(inputUser.attr("value") && inputMessage.attr("value"))
return true;
else
return false;
}
我这样写是不是一样
//check if all fields are filled
function checkForm(){
if(inputUser.attr("value"); inputMessage.attr("value"))
return true;
else
return false;
}
最佳答案
这是函数中的错误(以及指南,对他们来说是耻辱)。正确的应该是:
function checkForm(){
if(inputUser.attr("value") && inputMessage.attr("value"))
return true;
else
return false;
}
关于jquery - 为什么这个 jQuery 函数中使用 & 符号,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8307179/