Hi i using this code to highlight the input value when window on load and keyup
Currently only keyup is working - not works when the window is loaded
$(document).ready(function(){
$(".titleinput").keyup(function() {
if ($(this).val().length > 10) {
$(this).css("color", "red");
} else {
$(this).css("color", "#555");
}
});
});
Here is the working demo : https://codepen.io/creativedev/pen/QxqJmg
JS
var init = function () {
if ($('.titleinput').val().length > 10) {
$('.titleinput').css("color", "red");
} else {
$('.titleinput').css("color", "orange");
}
}
window.onload = init;
$(".titleinput").keyup(init);
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.