with(Div.style)
{
width='200px';
height='200px';
background='green';
}with(Div.style)中的Div.style是干什么意思?

解决方案 »

  1.   

    with(Div.style)
    {
    width='200px';
    height='200px';
    background='green';
    }
    with的用法相当于在一个规定的作用域里 执行某些操作 
    Div.style.width='200px';
    Div.style.height='200px';
    Div.style.background='green';但是我们一般都不推荐使用with 效率低
      

  2.   

    Div是dom对象Div.style是Div对象的style属性~·
      

  3.   


    with(Div.style)
    {
    width='200px';
    height='200px';
    background='green';
    }相当于
    Div.style.width='200px';
    Div.style.height='200px';
    Div.style.background='green';
      

  4.   

    with容易造成语义的歧义,所以并不常用比如with(Div.style)
    {
    width='200px';
    height='200px';
    background='green';
    anotherAttribute = 'sth';
    }
    anotherAttribute是Div.style的属性呢,还是with外边声明的某个变量呢?