Answer the question
In order to leave comments, you need to log in
How to set div block with contenteditable property?
Hello!
<div id="test" contenteditable></div>
#test{
width: 200px;
height: 25px;
border: 1px solid;
padding-left: 9px;
display: block;
border-radius: 4px;
};
let t = document.querySelector('#test');
t.addEventListener('keypress', function(e){
e.target.innerHTML = e.target.textContent.replace(
/hello/gim,
(p)=>{
return '<span style="color: red">'+p+'</span>'
}
);
});
div
( input ), because when entering text, the cursor returns to the beginning of the line each time and the inner text is turned upside down, just when using the replace( )
? css
or JS
disable line breaks when the enter key is pressed? As far as I understood in the inspector, these are not even line breaks, but this div, when you press the enter key, creates another one inside itself, with border
it turns out that this frame has nothing to do with what appears when you press the enter key (well, I think if you try to type something there, you will understand everything yourself), in fact, I need to simulate text input in a regular one input
or textarea
BUT it cannot be implemented in them regular expressions with dynamic text color replacement, so I actually look in the direction of this diva with this attributeAnswer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question