9

So I am using Jquery's load function like so,

$('#id').load("http://www.thisiswhyimbroke.com");

I know you can add id selectors after the url, but the content im looking for is not contained within an id, is there a way I can select a particular class name?

Even further, if I could select the first li item, then select the class with name item within it, is that possible?

Denys Séguret
  • 335,116
  • 73
  • 720
  • 697
Jupiter
  • 238
  • 1
  • 2
  • 11

1 Answers1

11

You can provide any selector, for example

$('#id').load("http://www.thisiswhyimbroke.com li:first .someclass");

From the documentation :

Loading Page Fragments

The .load() method, unlike $.get(), allows us to specify a portion of the remote document to be inserted. This is achieved with a special syntax for the url parameter. If one or more space characters are included in the string, the portion of the string following the first space is assumed to be a jQuery selector that determines the content to be loaded.

Denys Séguret
  • 335,116
  • 73
  • 720
  • 697