Javascript 我可以更改对象吗';大小以Js为单位?

Javascript 我可以更改对象吗';大小以Js为单位?,javascript,jquery,html,css,Javascript,Jquery,Html,Css,因此,我有一个对象,当在导航中单击时,我在其中加载数据。加载特定数据时是否有可能更改该对象的大小 <object id="box" width="250" height="250" data=""></object> 您应该单独设置每个属性,setAttribute函数不接受超过2个参数: .setAttribute("data", "sfw/danser.swf") .setAttribute('height', 600) .setAttribute('width',

因此,我有一个对象,当在导航中单击时,我在其中加载数据。加载特定数据时是否有可能更改该对象的大小

<object id="box" width="250" height="250" data=""></object>

您应该单独设置每个属性,
setAttribute
函数不接受超过2个参数:

.setAttribute("data", "sfw/danser.swf")
.setAttribute('height', 600)
.setAttribute('width', 150)

jQuery版本的
setAttribute
函数,即
attr
方法,接受一个对象:

$("#banner").on('click', function(event) {
   $("#box").attr({
       "data"   : "sfw/danser.swf", 
       "height" : 600,
       "width"  : 150
   });
});

您应该单独设置每个属性,
setAttribute
函数不接受超过2个参数:

.setAttribute("data", "sfw/danser.swf")
.setAttribute('height', 600)
.setAttribute('width', 150)

jQuery版本的
setAttribute
函数,即
attr
方法,接受一个对象:

$("#banner").on('click', function(event) {
   $("#box").attr({
       "data"   : "sfw/danser.swf", 
       "height" : 600,
       "width"  : 150
   });
});
由于它被标记,值得一提的是jQuery方式将允许
$(“#box”).attr({“data”:“swf/danser.swf”,“height”:“600px”,“width”;150px“})
由于它被标记,值得一提的是jQuery方式将允许
$(“#box”).attr({“data”:“swf/danser.swf”,“height”:“600px”,“width”;150px“})