在if语句

时间:2015-08-31 16:33:03

标签: php jquery if-statement

我有一个登录系统,我想要做的是隐藏div并在用户输入错误的登录详细信息时显示另一个div。但它似乎无法发挥作用。

if(...) { // here I check if the user enters the correct information

... //much code inside

} else { // if incorrect info, do this
    echo "<script>$('#jqueryhide2').hide();
        $('#jqueryhide').show();</script>";
}

尝试谷歌一点,但找不到任何可以解决我问题的东西。

3 个答案:

答案 0 :(得分:0)

您的语句中不需要脚本标记。您可以简单地执行以下操作。 (确保jqueryhide和jqueryhide2是DOM的一部分。)

if (blah == blah )
{
    $('#jqueryhide2').show();
    $('#jqueryhide').hide();
}
else
{
    $('#jqueryhide2').hide();
    $('#jqueryhide').show();
}

答案 1 :(得分:0)

put this code and also include your Jquery file -(dont forget)
echo "<script>
$('document').ready(function(){ 
$('#jqueryhide2').hide();
$('#jqueryhide').show();
});</script>";  

答案 2 :(得分:0)

我认为你应该错过这样的Onclick功能:

<script>
$('loginId').Onclick(function(){ 
$('#jqueryhide2').hide();
$('#jqueryhide').show();
});</script>";