html - Access normal text using jquery -


i have following html code:

<div class="top_l">     <a class="shou" onclick="" href="">11</a> |      <img border="0" class="" src="/">xxxxxx<a href=""></a> |      <a href=""></a> |      <a href=""></a>  </div>  

how text xxxxxx using jquery(what selector used)?

you can select element nodes jquery. , jquery methods consider element nodes, using jquery , plain dom api might approach here.

the text node want target next sibling of image. if can reference image element, can access text node .nextsibling [mdn] property:

var txt = image.nextsibling.nodevalue; // or if image jquery object var txt = image.get(0).nextsibling.nodevalue; 

given structure of html, this:

var txt = $('.top_l > img').get(0).nextsibling.nodevalue; 

demo


Comments

Popular posts from this blog

c++ - Function signature as a function template parameter -

algorithm - What are some ways to combine a number of (potentially incompatible) sorted sub-sets of a total set into a (partial) ordering of the total set? -

How to call a javascript function after the page loads with a chrome extension? -