Ankush Rathod

Ankush Rathod

  • 1.6k
  • 203
  • 7.5k

How to change color dynamically for specific text in val()

Jul 25 2017 10:48 AM
How to change color dynamically for specific text in jquery val() function.
- I want to change color for specific text and below is my code;
 
 $("#" + id).val("141"+ " " + "(Only 140 characters will be shown on Twitter)").css('color', 'red');
 
- I have implemented this code but red color has set for all text.
- I would like to set color red for "141" only.
- Also, I have tryed with different solution like, 1) using <span> tag for "141" text. 2) using append, But I'm not getting proper result.
- Please suggest me proper answer for this code. 
 

Answers (2)