Skip to content Skip to sidebar Skip to footer

Get Value Of Inside A Tag With Jquery.?

How can by jQuery get value inside tag b? hi_1hi_2hi_3hi_4 I want this

Solution 1:

Are you looking for something like this?

http://jsfiddle.net/ZDYnq/

$(document).ready(function() {
   var textArr = [];
   $('span b').each(function() {
     textArr.push($(this).text());
   });
    alert(textArr.join(', '));
});

Solution 2:

To get the value inside a specific HTML tag in jQuery you can use the text function. This combined with a selector gets the output you're looking for

$('span b').each(function() {
  console.log($(this).text());
});

JSFiddle

JSFiddle with commas

Solution 3:

This is cool

var x = $("span b").map(function() {
  return $(this).text();
}).toArray().join(", "); 

Demo here

Discussed here

Post a Comment for "Get Value Of Inside A Tag With Jquery.?"