emailg 2016-11-22 04:29 采纳率: 0%
浏览 3501

javascript里面两个if,为什么只有当第一个if括号里面为true时,下面的语句才可以执行?


function check() {

        if(Trim(document.reply.title.value) == "") {
            alert("please intput the title!");
            document.reply.title.focus();
            //return false;
        }

        alert("please intput the content!");

        if(Trim(document.reply.cont.value) == "") {
            alert("please intput the content!");
            document.reply.cont.focus();
            return false;
        } 

        return true;
    }

    javascript里面两个if,为什么只有当第一个if括号里面为true时,下面的语句才可以执行?
  • 写回答

4条回答 默认 最新

  • 斯洛文尼亚旅游 2016-11-22 04:52
    关注

    你下面的语句指什么,alert("please intput the content!");之后的?
    就你这个代码是不是true都会执行下面的代码,

    有个可能就是true不执行下面的,而不是执行下面的,为true会执行代码段,如果报错就不会继续执行了,而不是执行

    评论

报告相同问题?