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
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
Share Improve this question edited Aug 27, 2013 at 8:43 Hushme asked Aug 27, 2013 at 8:38 HushmeHushme 3,1441 gold badge22 silver badges27 bronze badges 2- jQuery or just Javascript? – Nikolaj Zander Commented Aug 27, 2013 at 8:47
- @Nikolaj Zander- please see the tags – Hushme Commented Aug 27, 2013 at 8:49
3 Answers
Reset to default 8You 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
var text= $("div strong").text();
updated
var text= $(a).filter('strong').text();
Here is how you get your Value from the string without jQuery:
var pageNum = a.substring(a.indexOf('<strong>' + 8, ), a.indexOf('</strong>'))
发布者:admin,转转请注明出处:http://www.yc00.com/questions/1744389060a4571814.html
评论列表(0条)