JavaScript Substitua espaços por traços
title = title.replace(/\s/g , "-");
Strange Sloth
title = title.replace(/\s/g , "-");
title = title.replace(/\s/g , "-");
var html = "<div>" + title + "</div>";
// ...