Jquery不执行函数选择语言webapp

时间:2015-11-21 11:17:16

标签: javascript jquery

让我解释一下我的问题:

其实我不知道怎么做,我也接受建议。我试图让用户在我的webbapp的第一步中选择$(document).ready的默认语言。然后,adter做出选择,我发送带有lan = es(西班牙语)或lan = en(英语)的cookie,以便在加载所有页面之前进行分析,然后显示一种语言或另一种语言。

所以,制定这个计划,我试着这样做:

型:

#choose-language-wrapper{ /* contenedor grande para eleccion de idioma */
    display: none;
    background-color: black;
    width: 95%;
    max-width: 95%;
    height: 95vh;
    z-index: 999;
    color: white;
    position: absolute;
    left: 2%;
    top: 2%;
}
    #choose-language-content{
        position: relative;
        margin: 0 auto;
        width: 80%;
        margin-top: 10%;
        text-align: center;
        font-family: 'Raleway', sans-serif !important;
    }
        #language-question h1{ /* pregunta en castellano */
            font-size: 3em;
            font-weight: bolder;
        }
        #language-question h3{/* pregunta en ingles */
            font-size: 2.5em;
            margin-top: 2%;
        }
    #language-ask-javascript{
        margin-top: 20%;
    }
        #language-ask-javascript button{ /* caracteristicas del button de eleccion de idioma */
            width: 300px;
            height: 100px;
            font-size: 3em;
            text-transform: uppercase;
            background-color: white;
            font-weight: 900;
            color: black;
            border: solid 3px white;
            -webkit-transition: all 0.5s ease;
            -o-transition: all 0.5s ease;
            transition: all 0.5s ease;
        }
        #language-ask-javascript button:hover{/* efectos del button :hover */
            cursor: pointer;
            color: white;
            background-color: black;
        }

HTML

<div id="choose-language-wrapper">
        <div id="choose-language-content">
            <div id="language-question">
                <h1>¿Qué idioma quieres como predefinido?</h1>
                <h3>¿What language do you want as default?</h3>
            </div>
            <div id="language-ask-javascript">
                    <button id="spanish">Español</button >
                    <button  id="english">English</button >
            </div>
        </div>
    </div>

JAVASCRIPT

$(document).ready(function(){
    $('#choose-language-wrapper').fadeIn('slow');
});

var a = function(){
    $('#spanishChoice').click(function(){
    document.cookie = "lan=es";

    $('#choose-language-wrapper').fadeOut();
    }
)};

var b = function(){
    $('#englishChoice').click(function(){
    document.cookie = "lan=en"

    $('#choose-language-wrapper').fadeOut();
    }
)};

我也试图不要声明“var'x'= function ...”而只是做

$('#englishChoice').click(function(){
        document.cookie = "lan=en"
        $('#choose-language-wrapper').fadeOut();

但它无论如何都没有用,我该怎么办? 有一种更好的方式去做我想做的事吗?我读到lan导航器并不总能成功运行!

0 个答案:

没有答案