Changing CSS styles with PHP and jQuery

前端 未结 2 724
面向向阳花
面向向阳花 2021-02-04 13:22

I\'m executing a PHP if/else statement.

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



        
相关标签:
2条回答
  • 2021-02-04 14:09

    Reckon you could do something like this:

    <?php
        if ($condition == true): 
             echo 'ITS TRUE!'; 
        else: 
    ?> 
        //put whatever html/style/script you want here, for example
        <script>
            $( '#id-element' ).css('display', 'none');
        </script>
    <?php endif; ?>
    
    0 讨论(0)
  • 2021-02-04 14:18

    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>';
    }
    
    0 讨论(0)
提交回复
热议问题