使用JQuery添加新按钮

Adding new button with JQuery

本文关键字:按钮 新按钮 JQuery 添加 使用      更新时间:2023-09-26

我试图创建一个按钮,当用户在文本框上写一些东西。我可以新建一个

按钮使用jQuery当用户点击按钮,但我如何立即创建新的按钮

当用户输入一些值使用JQuery?

谢谢…

首先,继续获取/读取用户输入的值,然后检查它是否与目标单词

匹配。

类似的代码:

$("#myTextField").on("keyup change ",  function () {
  //Now you want to compare your code here
  var text = $(this).val();
  if(text.indexOf("YES") > -1 )// -1 is the index of the string, -1 means it doesn't exist. 0 means it's the first occurrence in the string. 1 means it's at index 1. 
  {
    //Create your button here.     
  }
})

请参阅。keyup()或。change()。