Php, if () {} else & nbsp; {echo & quot; & lt; script & gt; $ (document ). ready (function () {$ (. captcha ). hide () ;}); & lt; script & gt; & quot ;;...... php code, omitted here} the result I want is the php,
If (){}
Else
{
Echo "script"
$ (Document). ready (function () {$ ('. captcha'). hide ();});
Script ";
... Php code, omitted here
}
The result I want is to hide the css of captcha class on the page when else is executed. But the code written above seems wrong. how can I add jquery code to the php judgment statement?
------ Solution --------------------
If the code is correct
PHP code
Echo <
------ Solution --------------------
Discussion
The third floor is incorrect,
------ Solution --------------------
This is easy
If (){
} Else
?>
Script // jquery script
}
?>
------ Solution --------------------
"; If this is more, add more points. what should I do if I have less points?
------ Solution --------------------
This JS code should be placed after the jquery. js file is introduced.
The key to the problem is what the html code output to the client is.
------ Solution --------------------
I already told you
But remember, this output must be controlled after your captcha has been properly output; otherwise, it will be invalid.
So you should output a hidden value in php, for example
Echo'';
After loading the entire page, perform corresponding operations based on this value.
JScript code
$ (Document ). ready (function () {if ($ ('# fool '). val () = 'false') {// execute code $ ('. captcha '). show ();}});
------ Solution --------------------
Discussion
Else
{
?>
Script
$ ('. Captcha'). show ();
Script
That's not the case.
------ Solution --------------------
You need to understand that php is running on the server, while js and jquery are running on the client, so when the html tag you need to operate is not displayed on the client, jquery cannot operate on the code. By understanding this, you will know how to do the rest.
------ Solution --------------------
Forget it. I will tell you a trick. if you are a normal person, I will not tell him. remember to give it a score ..
PHP code