Is there a way to select the text input values first letter and change its color via CSS in the stylesheet? so for example, I have ? scope : document;
var remote_id = element.getAttribute('form-remote-input');
var remote_element = scope.querySelector("#" + remote_id);
// Load initial value
element.textContent = remote_element.value;
// Add blur event updater var update_remote = function(e){
remote_element.value = element.textContent;
if(element.textContent == "") { // Remove extra <br>s that get addedwhile (element.firstChild) {
element.removeChild(element.firstChild);
}
}
}
element.addEventListener('blur', update_remote);
};
[].forEach.call(document.querySelectorAll('[form-remote-input]'), function(element){remote_input_updater(element)});
<body><divclass="text"id="first-red"data-placeholder="This is essentially an input"contenteditable="true"form-remote-input="remote-id"><!-- Must be no whitespace in here --></div><inputtype="hidden"id="remote-id" /></body>
Solution 2:
I don’t think that input boxes will allow changing the style of the first letter – it seems the OS does not make it possible. So you can make a div with contentEditable property equal to "true", and get its content with JavaScript, or a small workaround with two inputs aligned horizontally, or something. See this:
OK try to give your input a padding, wrap your input in a relative positioned div and then add a absolut positioned div with your " * " inside this padding of your textbox.
with jQuery or javascript hide the div on focus and show it again on blur if the value is empty
Post a Comment for "Select First Letter Of Input Value And Change It's Color Via CSS"