html icon indicating copy to clipboard operation
html copied to clipboard

getElementById does not support ids with point like "my.id"

Open a14n opened this issue 10 years ago • 0 comments

As getElementById(id) is defined by :

Element getElementById(String id) => querySelector('#$id');

It doesn't work with ids like my.id because it is handled as finding an element with id my and class id.

A workaround is:

//var elmt = getElementById('my.id);
var elmt = querySelectorAll('[id]').firstWhere((e)=> e.id == 'my.id');

a14n avatar Dec 15 '15 09:12 a14n