jQuery 自动完成插件不适用于 jQuery 1.4.1

发布于 2024-09-05 15:30:33 字数 1347 浏览 2 评论 0原文

我一直在使用 JQuery Autocomplete 插件和 JQuery 版本 1.3.2,它运行得很好。我最近将项目中的 JQuery 更新到版本 1.4.2,并且自动完成插件现在已损坏。将项目添加到我的网页上的文本框的 JQuery 代码似乎根本没有被调用。有谁知道 JQuery 自动完成插件是否与 JQuery 版本 1.4.2 不兼容,以及是否有解决此问题的方法?下面是我在 ASP.Net 网站中构建的一些示例代码(如果我将 JQuery 文件更改为 jquery-1.3.2.js,则可以正常工作,但使用 jquery-1.4.2.js 则不会发生任何情况):

<%@ Page Language="C#" AutoEventWireup="true"  CodeFile="Default.aspx.cs"    Inherits="_Default" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title>Untitled Page</title>
    <script type="text/javascript" src="js/jquery-1.4.2.js" ></script>
<script type="text/javascript" src="js/jquery.autocomplete.js" ></script>
<script type="text/javascript">
    $(document).ready(function() {
        var data = "Core Selectors Attributes Traversing Manipulation CSS Events    Effects Ajax Utilities".split(" ");
        $(':input:text:id$=sapleUser').autocomplete(data);
    }); 
</script>  
</head>
<body>
<form id="form1" runat="server">
    API Reference: <input id="sapleUser" autocomplete="off" type="text" runat="server" /> (try "C" or "E")  
</form>
</body>
</html>

I've been using the JQuery Autocomplete plugin with JQuery version 1.3.2, and it has been working great. I recently updated JQuery in my project to version 1.4.2, and the Autocomplete plugin is now broken. The JQuery code to add items to a textbox on my web page doesn't seem to be getting called at all. Does anyone know if the JQuery Autocomplete plugin is incompatible with JQuery version 1.4.2, and if there is a fix for this problem? Here is some sample code I've built in an ASP.Net web site (which works fine if I change the JQuery file to jquery-1.3.2.js, but nothing happens using jquery-1.4.2.js):

<%@ Page Language="C#" AutoEventWireup="true"  CodeFile="Default.aspx.cs"    Inherits="_Default" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title>Untitled Page</title>
    <script type="text/javascript" src="js/jquery-1.4.2.js" ></script>
<script type="text/javascript" src="js/jquery.autocomplete.js" ></script>
<script type="text/javascript">
    $(document).ready(function() {
        var data = "Core Selectors Attributes Traversing Manipulation CSS Events    Effects Ajax Utilities".split(" ");
        $(':input:text:id$=sapleUser').autocomplete(data);
    }); 
</script>  
</head>
<body>
<form id="form1" runat="server">
    API Reference: <input id="sapleUser" autocomplete="off" type="text" runat="server" /> (try "C" or "E")  
</form>
</body>
</html>

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

無處可尋 2024-09-12 15:30:34

事实证明,自动完成插件与 JQuery 版本 1.4.1 和 1.4.2 兼容。该问题是由我的 JQuery 选择器引起的:$(':input:text:id$=sapleUser'),它似乎与 1.4.x 版本的 JQuery 不兼容。我将选择器修改为:$('input[id$=sapleUser]'),现在它再次工作了。

It turned out that the Autocomplete plugin is compatible with JQuery ver 1.4.1 and 1.4.2. The problem was caused by my JQuery selector: $(':input:text:id$=sapleUser'), which appears not to be compatible with the 1.4.x versions of JQuery. I modified the selector to: $('input[id$=sapleUser]'), and it is now working again.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文