79743955

Date: 2025-08-23 01:11:27
Score: 2
Natty:
Report link

While Luca C.'s answer is specific on textarea element selection with :placeholder-shown and jQuery, I want to answer the more specific question Is there a way that I can select a textarea such that $('#id_of_textarea').val() in jQuery will be ''? combined with the following Is there an attribute for the text in a textarea?


While there is no attribute for the text in a textarea to select, if you refer to Attribute Selectors you have no other choice but to first add your own data-* attribute to the textarea element...

...but if you instead refer to specifically style the placeholder div element and text, you can simply use the ::placeholder pseudo-element like this:

textarea::placeholder {
  /* style properties */
}

thus these styling properties will apply only when the textarea has a placeholder text and has no "value" text

Reasons:
  • Blacklisted phrase (1): Is there a way
  • RegEx Blacklisted phrase (1): I want
  • Long answer (-0.5):
  • Has code block (-0.5):
  • Low reputation (1):
Posted by: Jack