我正在开发一个新项目 http://www.hotwirerevealed.com它显示/识别 hotwire.com 上的酒店。输入状态和目的地后,我有一个 javascript 函数,它使用 jquery 的 .post 方法进行发布。 post请求转到输出html的php页面,我使用jquery的html方法将内容放置在页面上。
像这样
function post(){
$.post("lookup.php", {action: "find", area: area, stars: stars, amenities: amenities, state: $('#state').val()}, function(data){
$("#details").html(data);
});
}
我有一些酒店的超链接,我喜欢在灯箱中使用这些链接
<a class="hotel" href="http://google.com/search?btnI=1&q=Amerisuites+Northeast+Orlando+(Airport+MCO)">Amerisuites Northeast</a>
我正在尝试使用jquery的花式框,但是花式框
$(document).ready(function(){
$(".hotel").fancybox({
'width' : '75%',
'height' : '75%',
'type' : 'iframe'
});
});
但它似乎不起作用,我猜是因为 jquery 不知道它在那里的元素?我尝试使用 jquery live() 方法但收效甚微,任何帮助将不胜感激,提前致谢
最佳答案
最快的方法是添加 livequery plugin到页面,
然后代替你的:
$(document).ready(function(){
$(".hotel").fancybox({
'width' : '75%',
'height' : '75%',
'type' : 'iframe'
});
});
这样做:
$(document).ready(function(){
$(".hotel").livequery(function(){
$(this).fancybox({
'width' : '75%',
'height' : '75%',
'type' : 'iframe'
});
});
});
关于php - AJAX 调用后使用 jquery 刷新 DOM,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2660736/