I have a contenteditable
element, I want elements inside to apply a style when the caret is inside them.
In this example the style changes on :hover
:
div{
caret-color: red;
}
span:hover {
font-weight:bold;
}
<div contenteditable="true">
<span>Sub element one</span>
text node
<span>sub element two</span>
</div>
Here you can see the caret as I have styled it in red, but I've hovered over the other span
:
Is there any way to apply a style like this, but when the caret is inside the element? So that the text in the span
around the red line is bold?
The solution would look like this:
A CSS solution would be ideal, but I would consider JS solutions if that's not possible.
|
is within the span – Meadowlark