Get the value of input text when enter key pressed

前端 未结 6 1338
温柔的废话
温柔的废话 2020-12-13 00:04

I am trying this:




        
6条回答
  •  臣服心动
    2020-12-13 00:19

    Try this:

      
    
    

    JS Code

    function search(ele) {
        if(event.key === 'Enter') {
            alert(ele.value);        
        }
    }
    

    DEMO Link

提交回复
热议问题