Search code examples
jqueryhtmlload

Loading whats inside of an "div" ajax jquery .load()?


I want to load the content(whats inside) of a DIV not the div itselfe?

the index.php:

$('header.teaserimage').load('gallery-uln8.php '+$ancor);

Structure of: gallery-uln8.php:

<div id="pic00">
   <img src="... ...>
</div>
...
<div id="picXX">
   <img src="... ...>
</div>

How can I accomplish this with the .load()- method of jQuery or should I use somwthing elese?


Solution

  • Following assumes that $anchor is a valid selector. load() is a shortcut ajax method as is $.get. They both pull in all that is output from the url. $.get just gives you a bit more flexibility

    $.get('gallery-uln8.php', function(data){
        $('header.teaserimage').html( $(data).find($ancor).html())
    
    });