输入类型=搜索无法正常工作

时间:2014-06-26 07:48:26

标签: jquery html html5 twitter-bootstrap

我有一个网络应用程序。使用jQuery,bootstrap和Kendo UI。我有一个用于搜索Kendo网格的FilterBox输入 - 我最初在标记中有type="text"但我更改了这个以利用html5 type =“seacrh”在用户输入时在字段中获取samll x - 但是某些原因这不起作用?我在chrome中测试了这个,我做了一个Ctrl和F5,以确保我完全重新加载页面?

输入字段电流如下:

<input id="txtSearch" type="search" placeholder="Type to Filter...">

在我的js中我有以下内容:

    var searchTextBox = $("#txtSearch");

    searchTextBox.on("change keyup paste mouseup", function () {
       // search logic
    });

2 个答案:

答案 0 :(得分:0)

我也在35.0.1916.153米,它的工作请检查这个小提琴。

http://jsfiddle.net/vMu3B/

var searchTextBox = $("#txtSearch");

    searchTextBox.on("change keyup paste mouseup", function () {
        var back = ["#ff0000","blue","gray"];
        var rand = back[Math.floor(Math.random() * back.length)];
            $("#divtest").css('background',rand);
    });

答案 1 :(得分:-2)

我认为你以错误的方式使用.on。根据文件http://api.jquery.com/on/,它应该是:

<div class="searchbox">
<input id="txtSearch" type="search" placeholder="Type to Filter...">
</div>

var searchTextBox = $(".searchbox");

    searchTextBox.on("#txtSearch","change keyup paste mouseup", function () {
       // search logic
    });