开发者

putting an underscore in its place

开发者 https://www.devze.com 2023-01-17 13:17 出处:网络
how do I take the string using jQuery S开发者_如何学编程tandard Class and turn it into this Standard_Class

how do I take the string using jQuery

S开发者_如何学编程tandard Class

and turn it into this

Standard_Class

if this is the id

$('#some_id').text;


Why do everything needs to be done with jQuery? How about a regex:

var result = 'Standard Class'.replace(/\s/g, '_');

and to modify the text into an existing element jQuery could be useful:

$('#some_id').text($('#some_id').text().replace(/\s/g, '_'));
0

精彩评论

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