Selecting an input element changes the border. How do I stop this with pure JS?
To change the input style in javascript, add an event listener to the input element:
document.getElementById("YOUR_INPUT_ID").addEventListener('focus', function() {
// as an example, i have set the background to red
document.getElementById("YOUR_INPUT_ID").style.backgroundColor = "red";
});
3 Likes
So I put
element.style.border = "";
To not have the orange focus border
1 Like
put element.style.borderStyle = 'none';
, an empty string won’t work.
2 Likes
You can set the outline to “none”
element.style.outline = "none";
I hope that helps
4 Likes
Is there a special reason it has to be in js? Css can do it too.
2 Likes
This is actually the solution, the default orange outline on input is outline not border
Yes, there is a special reason. I’m making a library.
2 Likes
This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.