jQuery - 找不到函数?
有人可以解释一下为什么下面的代码会抛出错误吗?
// 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
data
将是一个字符串。如果您希望
data
包含 HTML,请尝试data
is going to be a string.If you're expecting
data
to contain HTML, try因为
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.