简化js--函数返回

<script type="text/javascript">
function a(){
return false;
}
function b(){
return true;
}

function check(){
        if(a()&&b()){
        return true;
        }else{
        return false;
        }
}
</script>
<form action="http://www.cnblogs.com" onsubmit="return check()">
    <input type="submit"  value="提交"/>
</form>

上面的check函数可以简写为:

function check(){
       return a() && b() ? true :false;
}

 

 

posted @ 2013-10-29 15:00  tinyphp  Views(403)  Comments(0Edit  收藏  举报