I need to create an input type having text, of different color .
Ex. first 5 characters in color black and the rest in red
Is this possible with jquery or something ?
By input i mean
<input type="text" value="blackreddddd" />
Thank you.
I need to create an input type having text, of different color .
Ex. first 5 characters in color black and the rest in red
Is this possible with jquery or something ?
By input i mean
<input type="text" value="blackreddddd" />
Thank you.
You can create a function which can accept no of characters and then replace the html with the same.
Code for the same:
var str = $('#test').html();
function color(noOfCharacters) {
$('#test').html('<span style="color:red">' + str.substr(0, noOfCharacters) + '</span><span>' + str.substr(noOfCharacters, str.length) + '</span>');
}
color(4);