jquery to check when a someone starts typing in to a field

前端 未结 3 725
没有蜡笔的小新
没有蜡笔的小新 2021-02-20 11:49
$(\'a#next\').click(function() {
    var tags = $(\'input[name=tags]\');

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

    tags.addClass(\'hightlight\');  
    return false; 
    }else{
          


        
相关标签:
3条回答
  • 2021-02-20 12:31

    You want the focus event.

      $('a#next').focus(function() {
          $('#formcont').fadeIn('slow');
      });
    
    0 讨论(0)
  • 2021-02-20 12:36

    input#tags is redundant and wasteful.

    $('#tags').keypress(function() {
    
        $('#formcont').fadeIn('slow');
        $('#next').hide('slow');
        $(this).focus();
    });
    
    0 讨论(0)
  • 2021-02-20 12:50

    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();
    });
    
    0 讨论(0)
提交回复
热议问题