0

I am not ever sure this is possible but I know you guys will know the answer.

I wonder if it is possible to load the first div on a page into a different page.

Example:

This code is on "list.php"

<div class="message_details">
Some Content 1
</div>
<div class="message_details">
Some Content 2
</div>

I found this article and it works but it brings in all div's but I want to load only the first div.

Load content from external page into another page using Ajax/jQuery

Here is the code I have now that loads all divs

$(document).ready(function() {
    $(".loader").load('list.php .message_details');
});

How can I load only the first div? Also is there any way to remove an img tag within the selected div?

Thanks everyone

Community
  • 1
  • 1
BostonBB
  • 2,655
  • 3
  • 16
  • 12

2 Answers2

3

Use the :first-child selector

$(".loader").load('list.php .message_details:first-child', function() {
    $(this).find("img").remove();
});

Reference

Austin
  • 6,026
  • 2
  • 24
  • 24
0

simply echo the the div in the second page. Give each div an id, then echo that. (unless i am misunderstanding your goal)

ryno
  • 304
  • 5
  • 14