首页 > 这样改变行间样式对吗?

这样改变行间样式对吗?

为什么试了不行呢

window.onload=function(){
      var oDiv=document.getElementById('div1');
      var oIpt=document.getElementById('ipt1');
      oIpt.onfocus=function(){
        oDiv.style.className='form-group has-error';
      }
     }
<div class="container" style="
   margin-top: 100px;">
     <form>
        <div class="form-group" id="div1" style="width:45%">
         <input type="text" id="ipt1" class="form-control" id="name" 
         placeholder="请输入用户名">
        </div>
     </form>
   </div>

oDiv.classList.add('has-error')


oDiv.className='form-group has-error';

【热门文章】
【热门文章】