JS中style属性_javascript技巧
            
                    来源:动视网
                                        责编:小采
                                        时间:2020-11-27 20:33:31
                    
            
            
                         
                
                
                    JS中style属性_javascript技巧
                    JS中style属性_javascript技巧:现在我需要对这个标签赋值,其内容为: 1、需要显示的字为HELLO WORLD; 2、span的 background-color : red ,另外还要:border:1px solid #333333;cursor:hand; 我需要在内把他们赋值,请问怎么写呢?难道要: document.getElement
                    
                 
                
             
                        导读JS中style属性_javascript技巧:现在我需要对这个标签赋值,其内容为: 1、需要显示的字为HELLO WORLD; 2、span的 background-color : red ,另外还要:border:1px solid #333333;cursor:hand; 我需要在内把他们赋值,请问怎么写呢?难道要: document.getElement
                        
            

 现在我需要对这个标签赋值,其内容为: 
1、需要显示的字为“HELLO WORLD”; 
2、span的 background-color : red ,另外还要:border:1px solid #333333;cursor:hand; 
我需要在 script>内把他们赋值,请问怎么写呢?难道要: 
document.getElementById("a").style.background="red"; 来一项一项的写? 
能不能一下子把style写完啊,怎么写啊? 
解决办法:
1、先定义一个CSS规则,然后this.className=''
2、document.getElementById("a").style.cssText="border-collapse:collapse;border-spacing:1;border:1 solid #0B2565;background-color:white;color:black;" 
     
    
    
        JS中style属性_javascript技巧
        JS中style属性_javascript技巧:现在我需要对这个标签赋值,其内容为: 1、需要显示的字为HELLO WORLD; 2、span的 background-color : red ,另外还要:border:1px solid #333333;cursor:hand; 我需要在内把他们赋值,请问怎么写呢?难道要: document.getElement