我如何制作elem.setAttribute("style","border-top-right-radius: 5% 5%;");
发送此elem.setAttribute("style","border-top-right-radius: 5% x%;");
将最后5%设置为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%;");
答案 0 :(得分:0)
你可以连接字符串:
elem.setAttribute("style","border-top-right-radius: 5% " + x + "%;");
答案 1 :(得分:0)
试试这个
var x = string1/100 * 5;
elem.setAttribute('style','border-top-right-radius: 5%'+ x +'%;');