jquery - Getting value of element which is deep inside other elements -


i've got

<div class='test1'>     <div>..</div>     <div>         <span>...</span>         <span>target info</span>     </div> </div> 

how can target info span if know test1 class?

if html fixed show

to value of span can use eq() , text() follow.

eq(1) second element , text give innertext of element.

alert($('.test1 div').eq(1).find('span').eq(1).text());  // second span second div inside .test1 class element
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.10.1/jquery.min.js"></script>  <div class='test1'>    <div>..</div>    <div>      <span>...</span>      <span>target info</span>    </div>  </div>


Comments

Popular posts from this blog

javascript - Using jquery append to add option values into a select element not working -

Android soft keyboard reverts to default keyboard on orientation change -

jquery - javascript onscroll fade same class but with different div -