Note that there are some explanatory texts on larger screens.

plurals
  1. POPHP Conditional Question
    primarykey
    data
    text
    <p>Hello StackOverflow Community, I hope you guys can help me with this here:</p> <p>On my homepage I have a DIV structure that basically have a <code>&lt;div id="container"&gt;</code> that has an <code>&lt;h1&gt;</code> and a <code>&lt;div id="content"&gt;</code>.</p> <p>I also have some JavaScript that makes the <code>&lt;div id="content"&gt;</code> slide up/down when the <code>&lt;h1&gt;</code> is clicked, by inserting or removing a class ".open" to the <code>&lt;div id="content"&gt;</code>.</p> <p>Now I want to create using PHP and conditional that echo something if the <code>&lt;div id="content"&gt;</code> has the class ".open" and something else if not.</p> <p>This is what i was trying to do:</p> <p>There is a Javascript like this:</p> <pre><code> &lt;script type="text/javascript"&gt; $(function() { $('.container h1').bind('click', function() { if ($(this).parent().hasClass('open')) { $(this).parent().find('.content').slideUp(); $(this).parent().removeClass('open'); return 0; } $(this).parent().parent().find('.content').slideUp(); $(this).parent().find('.content').slideDown(); $(this).parent().addClass('open'); }) }); &lt;/script&gt; </code></pre> <p>That works on this:</p> <pre><code> &lt;div id="container"&gt; &lt;h1&gt;&lt;a href="javascript:void(null)"&gt;Open the content&lt;/a&gt;&lt;/h1&gt; &lt;div id="content"&gt; &lt;p&gt;Content 1&lt;/p&gt; &lt;/div&gt; &lt;/div&gt; &lt;div id="container"&gt; &lt;h1&gt;&lt;a href="javascript:void(null)"&gt;Open the content&lt;/a&gt;&lt;/h1&gt; &lt;div id="content"&gt; &lt;p&gt;Content 2&lt;/p&gt; &lt;/div&gt; &lt;/div&gt; </code></pre> <p>It works just fine until here. Now i want to create an condition with PHP that echo something when any has have the class .open but I cant figure out how to write this one. Here is what i came up with: </p> <pre><code> &lt;? if '#content'.class='open'{ echo include('column-right1.php'); echo include('column-right2.php'); } else { echo include('column-right3.php'); { ?&gt; </code></pre> <p>If this isnt possible in PHP how would be the script on javaScript and/or Jquery for it?</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload