Reputation: 3144
i want to extract value from the string
here is my Code
Js
var a = "<strong>1954</strong>im the text";
var pageNum = a.split("<strong>").slice(1)
alert(pageNum);
i simply want to extract value in strong tag i have tried but so far no luck
Upvotes: 2
Views: 1183
Reputation: 1270
Here is how you get your Value from the string without jQuery:
var pageNum = a.substring(a.indexOf('<strong>' + 8, ), a.indexOf('</strong>'))
Upvotes: 2
Reputation: 10388
var text= $("div strong").text();
updated
var text= $(a).filter('strong').text();
Upvotes: 2
Reputation: 388446
You can find the strong
element inside the div
and then get its contents using .text()
var pageNum = $("div").find('strong').text()
With the update
jQuery(function(){
var a = '<strong>1954</strong>im the text';
var pageNum = $(a).filter('strong').text();
alert(pageNum);
})
Demo: Fiddle
Demo: Fiddle
Upvotes: 8