Reputation: 44066
how do I take the string using jQuery
Standard Class
and turn it into this
Standard_Class
if this is the id
$('#some_id').text;
Upvotes: 0
Views: 72
Reputation: 1038780
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, '_'));
Upvotes: 4