2010-08-22 106 views
0

我構建一個URL,我有如何剝離的第一個字符

escape($('#count_of_stations').html() 

問題是值會在這樣

1 station 
2 stations 

我需要剝去其他一切則第一個字符,那麼有沒有辦法用「站點」發送它?

+2

如果有10個電臺怎麼辦?你還想要第一個字符嗎? – NullUserException 2010-08-22 02:56:17

+3

你的標題說「去掉第一個字符」,而在你說「去掉除第一個字符以外的所有東西」的問題中。你要哪個? – casablanca 2010-08-22 02:56:31

+0

不,只有5 – Trace 2010-08-22 03:14:37

回答

1

會使用substring工作嗎?

escape($('#count_of_stations').html().substring(0, 1)); 
0

如果措辭是一致的,我只是使用替換。 ('#count_of_stations')。text($('#count_of_stations')。text()。relace('station','stations'));

3
parseInt($('#count_of_stations').html()) 

就會丟棄較晚的非數字字符。

+0

+1,即使PO沒有明確說出它,我猜他想要的數字值。 – jessegavin 2010-08-22 03:06:44