How to get sibling element content by jQuery

If you want to get a sibling element in a variable by jQuery on your web page, follow these steps:How to get sibling element content by jQuery



1. First of all add some HTML code in your code file, like this:

<div class="container">
    <div class="demo">We will append this element in "result" class element:
</div>
<div class="target">
this is result.
</div>
<div class="another">
this is another content.
</div>
</div>


2. Then use siblings() function to get element, like this:

$(document).ready(function(){
  
    var myresult = $(".demo").siblings(".target").text();
    alert(myresult);

});


Now you will see your target element will show in the alert after the full page loaded, and output alert will look like this:

this is result.
How to get sibling element content by jQueryexpoundsofttechsolution d