Here the html code
<span class="setcategory2">
<img src="/images/dotes/travel.png">
TRAVEL
</span>
How can i get value of TRAVEL which is after img tag
Here the html code
<span class="setcategory2">
<img src="/images/dotes/travel.png">
TRAVEL
</span>
How can i get value of TRAVEL which is after img tag
$(function() {
var imgText = $('span.setcategory2').text(); //to get the text after img
$('div').text("The image text is: "+ imgText);
});
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<span class="setcategory2">
<img src="/images/dotes/travel.png">
TRAVEL
</span>
<div>
</div>
You can assign it to a variable like this...
var name = $('span').text();
Or if it was a specific span with an ID then...
var name = $("#idofspan").text();