Home > database >  not able to use title property in the document.getelementbyclass. error title property does not exis
not able to use title property in the document.getelementbyclass. error title property does not exis

Time:10-07

I want to assign some value where the class name is "grid-filter" but it's giving a compilation error in the angular typescript.

code

document.getElementByClassName('grid-filter')[0].title='new title';

CodePudding user response:

You need to cast the element returned to an array of HTMLElement since you're selecting by class name:

(document.getElementByClassName('grid-filter') as HTMLElement[])[0].title = 'new title';
  • Related