最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - Parsing Text with jQuery - Stack Overflow

programmeradmin4浏览0评论

I'm attempting to parse a text string with jQuery and to make a variable out of it. The string is below:

Publications Deadlines:   armadllo

I'm trying to just get everything past "Publications Deadlines: ", so it includes whatever the name is, regardless of how long or how many words it is.

I'm getting the text via a the jQuery .text() function like so:

$('.label_im_getting').text()

I feel like this may be a simple solution that I just can't put together. Traditional JS is fine as well if it's more efficient than JQ!

I'm attempting to parse a text string with jQuery and to make a variable out of it. The string is below:

Publications Deadlines:   armadllo

I'm trying to just get everything past "Publications Deadlines: ", so it includes whatever the name is, regardless of how long or how many words it is.

I'm getting the text via a the jQuery .text() function like so:

$('.label_im_getting').text()

I feel like this may be a simple solution that I just can't put together. Traditional JS is fine as well if it's more efficient than JQ!

Share Improve this question asked Oct 25, 2012 at 12:08 streetlightstreetlight 5,96813 gold badges66 silver badges102 bronze badges
Add a ment  | 

2 Answers 2

Reset to default 8

Try this,

Live Demo

First part

str = $.trim($('.label_im_getting').text().split(':')[0]);

Second part

str = $.trim($('.label_im_getting').text().split(':')[1]);
var string = input.split(':') // splits in two halfs based on the position of ':'
string = input[1] // take the second half
string = string.replace(/ /g, ''); // removes all the spaces.
发布评论

评论列表(0)

  1. 暂无评论