使用js在IE9中获取标签自定义属性

JScript code
   
   
   
   
function wfMain_DevNodeContextMenu(event) { var ele = event.target || event.srcElement; var devType = ele.devType; alert(devType ); }

HTML code
     
     
     
     
< a id ='bbbb' UserName ='ccccc' href ='javascript:;' devID ='001' devType ='525' oncontextmenu ='return wfMain_DevNodeContextMenu(event)' ></ a >
找了很久才发现,是ie9对自定义html标签属性不兼容。下面的代码是兼容的
 
   
   
   
   
JScript code
     
     
     
     
function wfMain_DevNodeContextMenu(event) { var ele = event.target || event.srcElement; var devType = ele.getAttribute("devType"); alert(ele.getAttribute("devType")); }

HTML code
       
       
       
       
< a id ='bbbb' UserName ='ccccc' href ='javascript:;' devID ='001' devType ='525' oncontextmenu ='return wfMain_DevNodeContextMenu(event)' ></ a >

你可能感兴趣的:(JavaScript,html,IE)