I have string like this,
var str="<svg width='321' height='987'></svg>";
I want to replace width
and height
of this string using JavaScript(widht and height is dynamic here).
I tried this
str.replace("width='", "width='100%");
But i know this will not work. i dont know how to replace text within specific string in javascript. Output should looks like,
var str="<div width='100%' height='100%'></div>";
Replace should be only for first occurrence within string.