Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Jquery load select a specific class

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?

like image 345
Jupiter Avatar asked Feb 03 '13 17:02

Jupiter


1 Answers

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.

like image 198
Denys Séguret Avatar answered Sep 30 '22 18:09

Denys Séguret