Hello there ,
var s = "width:20px;height:25px;color:red;font-family:myfontfamily";
i have a string like this,now how can i change the values of width,height etc using javascript.there may be a \\n
after or before the properties (width,height etc)..
Ex : i want to change width
to 50px
on s
. so it will be
var s = "width:50px;height:25px;color:red;font-family:myfontfamily";
My another replated Question is here Regular Expression to get text from css but it not working exactly what i need.
Please help me.
Thank you.
Update : You can see the Result on my fiddle here : http://jsfiddle.net/jitheshkt/s2DJR/14/
Regular expressions.
For example:
s = s.replace(/color:\s*([^;]+)/, "color:" + newvalue)
var s = "width:20px;\nheight:25px;\ncolor:red;\nfont-family:myfontfamily";
alert( s.replace(/width:\d+/,'width:123').replace(/height:\d+/,'height:456') );
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.