javascript - element.next() not working in IE8 -


i have 1 function in below few lines:

    if(ele.next())         {             if(ele.next().classname == 'errmark')                 ele.next().remove();          }  

now working fine browsers except 1 i.e. ie8 , getting error below:

webpage error details user agent: mozilla/4.0 (compatible; msie 8.0; windows nt 6.1; wow64; trident/4.0; slcc2; .net clr 2.0.50727; .net clr 3.5.30729; .net clr 3.0.30729; media center pc 6.0; cmdtdf; bri/1) timestamp: xxx   message: object doesn't support property or method line: 166 char: 5 code: 0 uri: xxxxxxxxxxxxxxxx 

somebody please me.. thanks..

i assume using jquery (ele.next() jquery syntax);

ele.next() give jquery object/element, not have .classname property. .classname property available in native javascript dom object, can access e.g. this: ele.next()[0]


you have 2 options here:

1 use javascript mixed jquery (not recommended):

if (ele.next()[0].classname === 'errmark') ele.next().remove();

2 use jquery (recommended):

if (ele.next().hasclass('errmark')) ele.next().remove();


and here's whole block - improved:

var next = ele.next(); if (next.length && next.hasclass('errmark')) next.remove(); 

Comments

Popular posts from this blog

c# - DetailsView in ASP.Net - How to add another column on the side/add a control in each row? -

javascript - firefox memory leak -

Trying to import CSV file to a SQL Server database using asp.net and c# - can't find what I'm missing -