better if viewed in img uploaded
function create(R,A){
var B=R;
var C=A;
// if i define a number e.g. 50% it works but when i
//pass a value it doesn't
img.style.top = "B%";
img.style.left = "C%";// same with c
}
答案 0 :(得分:0)
试试这个
function create(R,A){
var B=R;
var C=A;
img.style.top = B + "%";
img.style.left = C + "%";
}
您的代码无效,因为您已经为样式属性传递了“B%”,这是不正确的。你应该尝试B +“%”。
答案 1 :(得分:0)
你可以这样做
function create(R,A){
img.style.top = R+"%";
//pass a value it doesn't.
img.style.left = C+"%";
}
除非您正在修改函数的参数
,否则无需创建变量