javascript - 无法在 Cordova iOS 应用程序中添加自动完成功能

标签 javascript android jquery ios cordova

这是我的 html 代码,用于在 android cordova 项目中执行自动完成文本框,但它现在可以在 fiddle 中正常工作

    <!DOCTYPE html>

    <html>
        <head>

            <meta name="format-detection" content="telephone=no">
            <meta name="msapplication-tap-highlight" content="no">
            <meta name="viewport" content="user-scalable=no, initial-scale=1, maximum-scale=1, minimum-scale=1, width=device-width">
            <link rel="stylesheet" type="text/css" href="css/index.css">
            <title>Trial App</title>
              <script type="text/javascript" src="js/jquery.js"></script>
           <script type="text/javascript">
    $(document).ready(function() {

      var aTags = ["Krishna", "Shubham", "Sachin", "Android", "Windows", "Himalaya", "Bahubali", "Win", "Game"];

      $("#autocomplete").autocomplete({
        source: aTags
      });


      $('#get_value').on('click', getval);

      function getval() {

        var value_inside = $("#autocomplete").val();
        alert("Value inside text box is: " + value_inside);
      }

    });

  </script>
<body>
<input type='text' title='Tags' id='autocomplete' />
<button id="get_value">get</button>
</body>
</html>

fiddle 的链接是:https://jsfiddle.net/krishlahoti/g83x5wLz/

在 fiddle 中,我使用了与上述 HTML 文件中相同的代码, fiddle 可以正常工作,但 cordova 应用程序没有。

附上屏幕截图和这个问题以使其更清楚 Refer this screenshot for the Cordova iOS

最佳答案

经过大量研究和同事的帮助,我终于实现了我的目标。

下面是根据问题需要工作的最终代码:

<!DOCTYPE html>
<html>
<head>

</head>

  <script
              src="https://code.jquery.com/jquery-3.2.1.min.js"
              integrity="sha256-hwg4gsxgFZhOsEEamdOYGBf13FyQuiTwlAQgxVSNgt4="
              crossorigin="anonymous"></script>
  <script
              src="https://code.jquery.com/ui/1.12.1/jquery-ui.min.js"
              integrity="sha256-VazP97ZCwtekAsvgPBSUwPFKdrwD3unUfSGVYrahUqU="
              crossorigin="anonymous"></script>
  <script type="text/javascript">
    $(document).ready(function() {

      var aTags = ["Krishna", "Shubham", "Sachin", "Android", "Windows", "Himalaya", "Bahubali", "Win", "Game"];

      $("#autocomplete").autocomplete({
        source: aTags
      });


      $('#get_value').on('click', getval);

      function getval() {

        var value_inside = $("#autocomplete").val();
        alert("Value inside text box is: " + value_inside);
      }

    });

  </script>
<body>
<input type='text' title='Tags' id='autocomplete' />
<button id="get_value">get</button>
</body>
</html>

关于javascript - 无法在 Cordova iOS 应用程序中添加自动完成功能,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46903554/

相关文章:

javascript - 无法通过 JavaScript 单击呈现的输出

javascript - toggleClass 不会改变类

javascript - 如何使该复选框适用于新创建的任务?

java - 随机落体及碰撞检测方法

android - Main Activity 总是第一个启动的 Activity 吗?

位置为 "fixed"的菜单上的 jquery 动画填充

javascript - 如何缩短我的 jQuery 代码

android - AssetManager 列表返回 Assets 文件夹中没有的目录

javascript - jquery ajax 解析响应文本

javascript - 滚动到元素在 <ol> 中的位置