jQuery - 找不到函数?

发布于 2024-09-15 06:50:40 字数 614 浏览 2 评论 0原文

有人可以解释一下为什么下面的代码会抛出错误吗?

// JavaScript Document
$(document).ready(function(){
    $(".port-box").css("display", "none");
    $('ul#portfolio li a').bind('click', function(){
        var con_id = $(this).attr("id");
        if( con_id.length !== 0 ) {
            $.get('./act_web_designs_portfolio', function(data){
                var content = data.find("#" + con_id + "-content").html();
                alert(content);
            });
            return false;
        }
    });
});

火狐浏览器 说:

data.find 不是一个函数

非常感谢任何帮助,问候,Phil

could someone please explain why the following code is throwing an error?

// JavaScript Document
$(document).ready(function(){
    $(".port-box").css("display", "none");
    $('ul#portfolio li a').bind('click', function(){
        var con_id = $(this).attr("id");
        if( con_id.length !== 0 ) {
            $.get('./act_web_designs_portfolio', function(data){
                var content = data.find("#" + con_id + "-content").html();
                alert(content);
            });
            return false;
        }
    });
});

Firefox says:

data.find is not a function

Any help much appreciated, regards, Phil

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

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

发布评论

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

评论(2

千纸鹤 2024-09-22 06:50:40

data 将是一个字符串。

如果您希望 data 包含 HTML,请尝试

var content = $(data).find(....)

data is going to be a string.

If you're expecting data to contain HTML, try

var content = $(data).find(....)
缪败 2024-09-22 06:50:40

因为 data 不是 jQuery 对象 - 它通常是包含返回页面标记的字符串。

使用 $(data).find(...) 代替 - 这可能会做到这一点。

Because data is not a jQuery object - it's usually a string containing the markup of the returned page.

Use $(data).find(...) instead - that will probably do it.

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