Jquery: possible to change the text selection color in a textarea with jquery? css doesn't work :(
textarea::selection {
background:#0099ff;}
That's how you specify a text selection color for chrome in CSS, i know it's different for different browsers but I wanted to know if there's a way to change the selection color inside of a textarea, because the code above wont work for chrome, now, in the code above if i changed textarea
to p
then it would work on all the paragraphs. I noticed that the code above does开发者_开发技巧 work if I select the ENTIRE textarea, but not when selecting text in it.
Not 100% true. It should work in paragraphing, but not any other element. Try:
See here for a related answer to a related question.
Specifications
The ::selection CSS pseudo-element was drafted for CSS Selectors Level 3 but removed > before it reaches the Recommendation status. Despite this, it's implemented in some >browsers, which will probably retain experimental support for it.
Right now, the ::selection CSS pseudo-element is not in any specification on the standard track.
Browser compatibility
Chrome: 1.x, Firefox (Gecko): 1.0 (with -moz), Internet Explorer: 9, Opera: 9.5 or later, Safari: 1.1
Note: As said in that answer in the link, removed from the draft.
So basically, you can:
- Change non-selection color
but you can't:
- Change the selection color (not yet)
Note: Not all stuff in this answer maybe true.
you can't change the selection color for a textarea, you can only change it for non-input objects.
精彩评论