Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Changing CSS styles with PHP and jQuery

I'm executing a PHP if/else statement.

However, I want the code to do something like this :

<?php 

    if ($condition == true){ 
       echo 'ITS TRUE!'; 
    }else { 
       #id-element.css('display':'none'); 
    } 

?>

Note that the ELSE statement executes a jQuery line that changes the css style of the element involved.

How do i go about doing this?

Anyone have any suggestions / examples of how I could implement a PHP if/else and change css styles with jQuery inside the PHP if/else statement?

like image 759
Kyle Yeo Avatar asked Jan 13 '13 13:01

Kyle Yeo


1 Answers

You can echo the HTML for a style element and throw the CSS inside that.

else {
    echo '<style type="text/css">
        #id-element {
            display: none;
        }
        </style>';
}
like image 165
Will Avatar answered Sep 23 '22 08:09

Will