Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6561103
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T13:32:46+00:00 2026-05-25T13:32:46+00:00

Hello StackOverflow Community, I hope you guys can help me with this here: On

  • 0

Hello StackOverflow Community, I hope you guys can help me with this here:

On my homepage I have a DIV structure that basically have a <div id="container"> that has an <h1> and a <div id="content">.

I also have some JavaScript that makes the <div id="content"> slide up/down when the <h1> is clicked, by inserting or removing a class “.open” to the <div id="content">.

Now I want to create using PHP and conditional that echo something if the <div id="content"> has the class “.open” and something else if not.

This is what i was trying to do:

There is a Javascript like this:

            <script type="text/javascript">
                  $(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');
                        })
                     });
            </script>

That works on this:

            <div id="container">
                <h1><a href="javascript:void(null)">Open the content</a></h1>
                <div id="content">
                    <p>Content 1</p>
                </div>  
            </div>      
            <div id="container">
                <h1><a href="javascript:void(null)">Open the content</a></h1>
                <div id="content">
                    <p>Content 2</p>
                </div>  
            </div>     

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:

            <? if '#content'.class='open'{
                  echo include('column-right1.php'); 
                  echo include('column-right2.php'); 
                }
                else {
                  echo include('column-right3.php');  
                {
            ?>

If this isnt possible in PHP how would be the script on javaScript and/or Jquery for it?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-25T13:32:47+00:00Added an answer on May 25, 2026 at 1:32 pm

    If it were me I would use jquery and do something like this:

    1. give an id to div where you’re appending “.aberto” like id=”content” class=”content aberto”
    2. Check if the class exists
    3. Load the php file you want
    if ($('#content').hasClass('aberto')) {
       $("#some_div_id").load('column-right1.php');
       $("#other_div_id").load('column-right2.php');
    }else{
       $("#else_div_id").load('column-right3.php');
    }
    

    Adapt it and try it 😉

    You should start by including a file in your index.php right before closing the tag … something like:

    <script type="text/javascript" src="http://www.daterraweb.com/js/onload.js"></script>
    

    Then in file onload.js you place the code mentioned above… like

    $(document).ready(function(){
     if ($('#content').hasClass('aberto')) {
           $("#some_div_id").load('column-right1.php');
           $("#other_div_id").load('column-right2.php');
        }else{
           $("#else_div_id").load('column-right3.php');
        }
    }
    
    1. You should be carefull with the paths for php files
    2. You should have all the important divs with the id desired and match it with the jquery code.

    NOTE: If you want to load the content right after you insert the .open class you should simply change to something like this:

           <script type="text/javascript">
                  $(function() {
                        $('.container h1').bind('click', function() {
                            if ($(this).parent().hasClass('open')) {
                                $(this).parent().find('.content').slideUp();
                                $(this).parent().removeClass('open');
                                $("#else_div_id").load('column-right3.php');
                                return 0;
                            }
                            $(this).parent().parent().find('.content').slideUp();
                            $(this).parent().find('.content').slideDown();
                            $(this).parent().addClass('open');
                            $("#some_div_id").load('column-right1.php');
                            $("#other_div_id").load('column-right2.php');
                        })
                     });
            </script>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Hello StackOverflow community, The air.swf file referenced here: http://livedocs.adobe.com/flex/3/html/help.html?content=distributing_apps_3.html used to launch AIR applications
Hello StackOverflow'ers, I have a (flex) app that, on the click of a button,
I have an arraylist that contains urls in the form similar to : stackoverflow.com/questions/ask/hello
Hello can anybody solve this please I'm creating the object in the action class
Hello I am working with a simulator that uses rcS scripts to boot, this
Hello stackoverflow community ! I am trying to figure out how to architect my
Hello StackOverflow community, Using Google App Engine, I wrote a keyToSha256() method within a
Hello StackOverflow community, Is there any way to open a folder in Windows Explorer
Hello StackOverflow community, Is there any way to package the installer for an Adobe
Why hello there Stackoverflow, I have a nutcracker for ya, is there an good

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.