Question

How can i make elem.setAttribute("style","border-top-right-radius: 5% 5%;"); To send this elem.setAttribute("style","border-top-right-radius: 5% x%;");

Sett the last 5% to the value of var x.

var element1 = document.getElementById("content"),
style = window.getComputedStyle(element1),
height = style.getPropertyValue('height');

var string1 = height;
string1 = string1.replace(/\D/g,'');

var x = string1 / 100 * 5;
alert(string1);
alert(x);


var elem = document.getElementById("content");
elem.setAttribute("style","border-top-right-radius: 5% 5%;");
Was it helpful?

Solution

You can just concetenate strings:

elem.setAttribute("style","border-top-right-radius: 5% " + x + "%;");

OTHER TIPS

Try this

var x = string1/100 * 5;
elem.setAttribute('style','border-top-right-radius: 5%'+ x +'%;');
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top