jQuery: inside an element

0 Sampan Verma · May 16, 2015
First of all thanks for helping.

I have selected an element suppose div. The div contains other span elements. Through the div i want to select the spans inside it. How should fo it?

by through the div i mean using the select div in $ to find the child span.

Post a Reply


Oldest  Newest  Rating
0 Azim Udin · May 16, 2015
i am not entirely sure what you are looking for....

you can use
$('div > span').SomeMethod();
or may be...

this might help

0 Sampan Verma · May 17, 2015
Thanks for help but thats not what im looking for.


0 Sampan Verma · May 17, 2015
Thanks for help but thats not what im looking for.


0 Sampan Verma · May 17, 2015

??? is how to select a span elem inside this element any cool function name.

?? is how to get its html content
0 Sampan Verma · May 17, 2015
So I need a answer. Thanks for replying
0 Superman HC · May 18, 2015
If i get what's you are looking,, you are asking how to get some function performed on an element that is a child of a div...
If yes.. then look for the code below.. i have created a simple code for counting the elements: 

<div id="ref">
<h2>More blahblah</h2>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="demo.js"></script>


/* JS CODE */

var z = $('#ref span').find('*').length;

0 Ali Hassan · May 18, 2015

// if you are trying to select a certain span

0 Abdullah Nauman · May 18, 2015
Why is this never used? 

0 Sampan Verma · May 18, 2015
Thanks Everyone again.

Keylor Renslow got this right.

Ravi Ahuja, I tried to that one but believe me its is just a pain in the butt.
  • 1



A scripting language that is added to standard HTML to create interactive effects, apps, games for the browser.