0

I have:

$(document).ready(function() {
  $('#newslinks a').click(function() {
     var url=$(this).attr('href');
     $('#headlines').load(url + ' #newsItem');
     return false;
  }); //end click
}); // end ready



<div class="wrapper">
  <div class="header">
    <p class="logo">JavaScript <i>&</i> jQuery <i class="mm">The<br>Missing<br>Manual</i></p>
  </div>
  <div class="content">
    <div class="main">
      <h1>News Headlines</h1>
      <ul id="newslinks">
        <li><a href="today.html">Today&#8217;s News</a></li>
        <li><a href="yesterday.html">Yesterday&#8217;s News</a></li>
        <li><a href="lastweek.html">Last Week&#8217;s News</a></li>
      </ul>
      <div id="headlines"></div>
    </div>
  </div>
  <div class="footer">
    <p>JavaScript &amp; jQuery: The Missing Manual, by <a href="http://sawmac.com/">David McFarland</a>. Published by <a href="http://oreilly.com/">O'Reilly Media, Inc</a>.</p>
  </div>
</div>

The part that I don't get is in here:

$('#headlines').load(url + ' #newsItem');

What exactly does #newsItem do here?

1

1 Answer 1

1

The selector inside load after the URL will load that specific element's content into your target element. $('#headlines').load(url + ' #newsItem'); loads the URL, then within, finds #newsItem, and loads that content into #headlines

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.