jQuery代码,不了解 [英] jQuery code, not understanding

查看:80
本文介绍了jQuery代码,不了解的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在看这段代码,因为我是网页设计的新手,所以我无法理解它.

I am looking at this code and as I'm new to web design I'm unable to understand it.

因此,在我的索引页面上,我有一个指向google的链接,在ext.js页面上有以下代码.

So on my index page I have a link to google and the ext.js page the following code.

这是我所理解的,这是错误的.

This is what I understand which is wrong.

用户单击okcancel,因此变量cokcancel.现在,我看不到if语句的意义,因为它是okcancel,换句话说,是true或false.

The user clicks ok or cancel, therefore the variable c is either ok or cancel. Now I don't see the point of the if statement, because it will be either ok or cancel on other words true or false.

$(window).unload(function(){
    var c = confirm('Are you sure you want to leave?');
    if(c){ 
        return true;
    }else{
        return false;
    }
});

推荐答案

变量c可以确定或取消

the variable c is either ok or cancel

否,它是truefalse,取决于按下的是确定"还是取消"(或所涉及浏览器的本地i18ned版本).

No, it will be true or false depending on which of OK or Cancel (or whatever the local i18ned version is for the browser in question) was pressed.

我看不到if语句的要点

i dont seee the point of the if statement

没有意义.

return confirm('Are you sure you want to leave?');

…更简洁地给出相同的结果.

… gives the same result, much more concisely.

这篇关于jQuery代码,不了解的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆