tags:

views:

118

answers:

3
$('a#next').click(function() {
    var tags = $('input[name=tags]');

    if(tags.val()==''){

    tags.addClass('hightlight');  
    return false; 
    }else{
    tags.removeClass('hightlight');
    $('#formcont').fadeIn('slow');
    $('#next').hide('slow');
        return false;
    }
});

I would like the above code to fire the fadeIn as soon as somebody starts typing into the tags input. Can somebody tell me the correct way to do this or point me in the right direction? Thanks in advance

EDIT

here is the code to do it:

$('input#tags').keypress(function() {

    $('#formcont').fadeIn('slow');
    $('#next').hide('slow');
});

The only problem I've found is that my cursor no longer shows up in the text box. What am I doing wrong?

+1  A: 

You want the focus event.

  $('a#next').focus(function() {
      $('#formcont').fadeIn('slow');
  });
Dead account
If he wants something to happen when they start typing, then this won't do what he needs.
Russell Steen
but keypress will fire with every keypress not just the first
Dead account
+1  A: 

If #tags is your id, then input#tags is redundant and wasteful.

$('#tags').keypress(function() {

    $('#formcont').fadeIn('slow');
    $('#next').hide('slow');
    $(this).focus();
});
A Rad
+1  A: 

Sounds like the fade is moving your focus, hence the cursor no longer being there. Try this

$('input#tags').keypress(function() {

    $('#formcont').fadeIn('slow');
    $('#next').hide('slow');
    $(this).focus();
});
Russell Steen