How to change input border-color, with jQuery, depending on its value? -


i have question jquery. have code below works fine; changes input border-color depending on value, typed , entered. if in input's value on page-load not change border-color. how can make border-color change beginning, following page-load?

thank :)

<input type="text" class="col" value="">   // when <input>'s value changes $("input").change(function() {  // if value less 7, add red border if ($(this).val() < 7) {     $(this).css("border", "5px solid red"); }  // else if value equal 7, add green border else if ($(this).val() == 7) {     $(this).css("border", "5px solid green"); }  // else if value greater 7, add orange border else if ($(this).val() > 7) {     $(this).css("border", "5px solid orange"); }  // else if value else, add black border else {     $(this).css("border", "5px solid black"); }  }); 

just trigger event:

$("input").change(function() {     // ... }).trigger("change"); 

demo: http://jsfiddle.net/9b5sx/1/


Comments

Popular posts from this blog

SPSS keyboard combination alters encoding -

Add new record to the table by click on the button in Microsoft Access -

CSS3 Transition to highlight new elements created in JQuery -