replace hyphen with a space for the text given in the div

jquery

Solution

Try

var value = $('div').text();
$('div').text(value.replace(/\-/g, " "));

Demo: Fiddle

Problem

``` <div>This-is-text-1</div> ``` Given the code line ``` var value = $('div').text(); ``` I need to replave the hyphens `-` to an empty space ``. The output I require is " This is text 1 "How can I use the jQuery replace function here?

Original source