Amoro Amoro - 2 months ago 5
Javascript Question

Specifiy input targeted blur function

My function works as it should. is there a way to remove the function from a specific input? Because it changes all inputs.. i have 2 check boxes and 1 input that i need to not have this function on.

$('input').blur(function(){
$('input').parent().removeClass("gray");
})
.focus(function() {
$(this).parent().addClass("gray")
});

Answer

Try adding a class to the input and checkbox that you don't want the onblur functions, then update the code as below

Add the class to the three inputs that you don't want this feature

$('input').not( ".class" ).blur(function() {
    $(this).parent().removeClass("gray");
  })
  .focus(function() {
    $(this).parent().addClass("gray")
  });

Hope this helps what you need.