Can I apply a CSS style to an element name?

后端 未结 10 1389
借酒劲吻你
借酒劲吻你 2020-12-07 14:39

I\'m currently working on a project where I have no control over the HTML that I am applying CSS styles to. And the HTML is not very well labelled, in the sense that there a

10条回答
  •  北荒
    北荒 (楼主)
    2020-12-07 14:52

    If i understand your question right then,

    Yes you can set style of individual element if its id or name is available,

    e.g.

    if id available then u can get control over the element like,

    
    
    var v_obj = document.getElementsById('goButton');
    
    v_obj.setAttribute('style','color:red;background:none');
    

    else if name is available then u can get control over the element like,

    
    
    var v_obj = document.getElementsByName('goButton');
    
    v_obj.setAttribute('style','color:red;background:none');
    

提交回复
热议问题