在if语句中执行jquery

I got a login system, and what I want to do is to hide a div and show another div when the user types the incorrect login details. However it doesn't seem to work.

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>";
}

Tried to google a bit but can't find anything that could solve my problem.

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

You don't need the script tags inside your statement. You can simply do the following. ( Make sure jqueryhide and jqueryhide2 are a part of the DOM. )

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

I think you should missing the Onclick function like this:

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