开发者

how to jquery replace space also

开发者 https://www.devze.com 2023-01-19 23:48 出处:网络
$(this).html().replace(\"0 days\",\"\"); i want to replace \"0 days\" to become \"\". Currently the above statement will replace \"0\" to \"\" . that is not what i want. i want to replace entire sta
$(this).html().replace("0 days","");

i want to replace "0 days" to become "". Currently the above statement will replace "0" to "" . that is not what i want. i want to replace entire statement开发者_C百科 "0 days"


This will replace only the first occurrence. If you want to replace all occurrences:

$(this).html().replace(/0 days/g, '');

Example:

alert('foo 0 days bar 0 days foobar'.replace(/0 days/g, ''));

shows:

foo bar foobar


http://www.jsfiddle.net/jrJga/

works fine here..

0

精彩评论

暂无评论...
验证码 换一张
取 消