style a div using escaped URL parameters

后端 未结 2 1861
清酒与你
清酒与你 2021-01-26 13:30

I\'m new in javascript and i don\'t exactly understand how to modify this code to style a div:

function getParameters() {
  var searchString = document.getElemen         


        
2条回答
  •  伪装坚强ぢ
    2021-01-26 14:15

    With the javascript function styleDiv you can pass the url string of style (style=value) and the targets (DOM element tag name, id, class). It will find those targets, and set styles.

    Kudos to Banana for using element.style[property] = value, i didn't know about it.

    jsFiddle link

    
    
      
      Style a Div
    
      
    
    
      
    
    
    
    
    
    
    
    
      
    Hello world

提交回复
热议问题