1

I have this code....

  <div id="details">
                    <nav>
                            <a href="#1"><span>Summary</span></a>
                            <a href="#2"><span>Personal</span></a>
                    </nav>
                </div>

        <div id="1" class="navLinks"> <?php include 'includes/i_includes/summary.php';?> </div>
        <div id="2" class="navLinks"> <?php include 'includes/i_includes/info.php';?> </div>

and then I also have this script

<script type="text/javascript">

        $('nav a').click(function() {

          $('.navLinks').hide();
          $(this.getAttribute('href')).show()
        });


        </script>

I would like to make so on page load... the content of Summary is automatically shown..

Kmiles1990123
  • 189
  • 2
  • 12

2 Answers2

3

you can use .filter().click()

$('nav a').click(function() {
     $('.navLinks').hide();
     $(this.getAttribute('href')).show()
}).filter('[href="#1"]').click();

Working Demo

or you can use .eq().click();

$('nav a').click(function() {
    $('.navLinks').hide();
    $(this.getAttribute('href')).show()
}).eq(0).click();

Working Demo

Mohamed-Yousef
  • 23,946
  • 3
  • 19
  • 28
0

Use this sricpt:

$(document).ready(function() {
 $("#yourdivid").show();
 });

Check on Following Links:

Show div after 2 seconds of page load

Hide div with specific class while page is loading then show again after load

Community
  • 1
  • 1
Yagnik Detroja
  • 921
  • 1
  • 7
  • 22