I am trying to set a checkbox with a label to work so that when you select text in a contenteditable div clicking on the label does not lose the selection from the div . On the label, you still need to apply the standard tick / untick flag when you click on it, but keep the focus and the attenuation selected on the div .
Performing a simple focus() on a div will not help, since the selection will be removed (and the carriage at the beginning). I could, of course, learn how to store the selection object and try to assign it after clicking the label , but is there an easier way to save the selection ?
(the reason I need to do this with label and checkbox is because I will use jQuery UI buttons and I will need their toggle function)
Similarly, if you check the box, you usually save the selection in a div , but at least on FF4, if you click this checkbox very often (<1s), it will lose the selection. Any idea what is going on there? answered below
example: http://jsfiddle.net/niklasvh/gULM9/
source share