Jquery Show Input Text Based On Input Value

前端 未结 5 1324
感动是毒
感动是毒 2021-01-21 05:35

I facing problem with my jquery, on showing input text based on input value. Here is the JS fiddle demo :

http://jsfiddle.net/Ltapp/364/

When I try to input @hot

5条回答
  •  南方客
    南方客 (楼主)
    2021-01-21 05:56

    You're affecting all inputs. Either give each one a unique ID / Class or use the jQuery $(this) method.

    See JSFiddle Here:

    http://jsfiddle.net/Ltapp/366/

    
    

    var myString = '@hotmail'; $('#secondinput').hide(); $("#firstinput").keyup(function () { var value = $(this).val(); if($(this).val().match(myString)) { $('#secondinput').show(); } else { $('#secondinput').hide(); } });

提交回复
热议问题