What is the equivalent of a simple Javascript .each, and $(this).findwhen used in this example?
$(document).ready(function(){
$('.rows').each(function(){
var textfield = $(this).find(".textfield");
var colorbox = $(this).find(".box");
function colorchange() {
if (textfield.val() <100 || textfield.val() == null) {
colorbox.css("background-color","red");
colorbox.html("Too Low");
}
else if (textfield.val() >300) {
colorbox.css("background-color","red");
colorbox.html("Too High");
}
else {
colorbox.css("background-color","green");
colorbox.html("Just Right");
}
}
textfield.keyup(colorchange);
}
)});
Here is the fiddle basically what I am trying to execute, I know that I need to use a loop. I'm just not sure how to set it up. I don't want to use jquery just for this simple function, if I don't need
http://jsfiddle.net/8u5dj/
I deleted the code that I already tried because it changed every instance of colorbox, so I'm not sure what I did wrong.
source
share