Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
您如何确定从.get()请求中检索的数据是否包含带有特定选择器的 html?
.get()
$.get(url,function(data){ alert( data.find("#myid").length ) });
似乎不起作用。
假设数据是一些 HTML,使用
$(data).find("#myid").length
如果您的文档格式不正确,或者这个更可靠的解决方案:
$("<div>").html(data).find("#myid")
你应该做$(data).find
$(data).find