get html content of next element with a defined classname

Posted by Carasuman on Stack Overflow See other posts from Stack Overflow or by Carasuman
Published on 2012-10-21T04:23:45Z Indexed on 2012/10/21 5:01 UTC
Read the original article Hit count: 110

Filed under:
|

i have problems with jquery.. If i have this code to fill tooltip div

<div id="tooltip"></div>
<div class="tooltipMessage">Tooltip Message</div>
<script type="text/javascript">
   $("#id").html($("#tooltip").next(".tooltipMessage").html());
</script>

Works, the code takes the next element with classname "tooltipMessage" and fills element with id "tooltip".

But if i have this code:

<div id="tooltip"></div>
<p>other element</p>
<div class="tooltipMesage">Tooltip Message</div>

Returns "undefined". How i can take html from the next element with classname "tooltipMessage" if exists another element in middle ?

Thanks for help!.

© Stack Overflow or respective owner

Related posts about JavaScript

Related posts about jQuery