javascript set className property for Internet Explorer

I set className property of a dinamically generated select control with the following code: oField.className ="select"; It works for Firefox not for Internet Explorer. How can I set this property on IE? The code: var oField = document.createElement("select"); if(browser == "IE"){ oField.size = 1; oField.setAttribute("name","sele"+num); oField.onChange = function(){ AggiungiRiga(,oField.value) }; } else{ oField.setAttribute("size",1); oField.setAttribute("name","sele"+num); oField.setAttribute("onChange","AggiungiRiga(,this.value)"); } oField.className ="select"; Here I add it to the document: oTd1.appendChild(oField); (`oTd1` is the `` element where the select control must be place). I know the code is not of good quality cause is legacy code.
Assuming that oField is an HTMLElementNode, that should work just fine in IE. Your problem likely lies elsewhere.

以上就是javascript set className property for Internet Explorer的详细内容,更多请关注web前端其它相关文章!

赞(0) 打赏
未经允许不得转载:web前端首页 » JavaScript 答疑

评论 抢沙发

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址

前端开发相关广告投放 更专业 更精准