在 HTML 文本输入中选择文本时更改突出显示颜色 [英] Changing the highlight color when selecting text in an HTML text input

查看:27
本文介绍了在 HTML 文本输入中选择文本时更改突出显示颜色的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直在整个网络上寻找这个,甚至找不到其他人甚至问这个,更不用说解决方案了...

I've been looking for this throughout the web and can't even find anyone else even asking this, let alone a solution...

有没有办法在选择文本时更改文本输入中突出显示区域的颜色?不是高亮边框或背景,而是当您实际选择文本时出现在文本周围的部分.

Is there a way to change the color of the highlight area within a text input when text is selected? Not the highlight border or the background, but the portion that appears around the text when you have the text actually selected.

推荐答案

感谢您提供的链接,但似乎实际的文本突出显示并未暴露出来.

Thanks for the links, but it does seem as if the actual text highlighting just isn't exposed.

就手头的实际问题而言,我最终选择了一种不同的方法,完全不需要文本输入,并使用带有一些 JavaScript 的 innerHTML.它不仅绕过了文本突出显示,实际上看起来更干净了.

As far as the actual issue at hand, I ended up opting for a different approach by eliminating the need for a text input altogether and using innerHTML with some JavaScript. Not only does it get around the text highlighting, it actually looks much cleaner.

对 HTML 表单控件的这种细化调整是完全消除表单控件的另一个很好的论据.哈哈!

This granular of a tweak to an HTML form control is just another good argument for eliminating form controls altogether. Haha!

这篇关于在 HTML 文本输入中选择文本时更改突出显示颜色的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆