I am trying to add checkbox which says: "Enable Snap: []". If user click on that checkbox i want to check that checkbox is checked or not. But i am getting error like: document.getElementById(...) is null.
Below is the code:
instance.setHeaderItems(header => {
header.getHeader('toolbarGroup-Annotate').unshift({
type: 'customElement',
render: function() {
const checkbox = document.createElement('input');
checkbox.type = 'checkbox';
checkbox.name = 'snap-to-grid';
checkbox.value = '1';
checkbox.id = 'snap-to-grid';
checkbox.onclick = function(evt) {
alert(document.getElementById('snap-to-grid').checked);
};
return checkbox;
}
});
});
So is there a way to know that checkbox is checked or not? Also how can i add some text before checkbox?