I have the following code: <div #test (click)="onClick(test)" contenteditable="true"> This text can be edited by the user. </div> @ViewChild('test') el:ElementRef; constructor(private elementRef: ElementRef) {} onClick(event) { console.log(this.el.nativeElement); let cursor = this.el.nativeElement.selectionStart; //gives undefined } How do I get the cursor position for the 'div' element when user clicks on the text? Continue reading...