jQuery Form How to - Fade in an input








Question

We would like to know how to fade in an input.

Answer


<!DOCTYPE html>
<html>
<head>
<script type='text/javascript'
  src='http://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js'></script>
<style type='text/css'>
#myField {<!--from   w  w  w .ja  v a2 s  .c  om-->
  opacity: 0.2;
}
</style>
<script type='text/javascript'>
$(window).load(function(){
    $("#myField").focus(function(event){
        console.log("focus");
        $(this).fadeTo('slow', 3);
    });
});
</script>
</head>
<body>
  <input type="text" id="myField" value="Here is some">
</body>
</html>

The code above is rendered as follows: