我已使用 iframe
在 Fancybox 中加载了一个页面。但是当我尝试在该 iframe
中执行 jQuery 函数时,它不起作用。如何访问 iframe
页面或内容,以便可以在该页面上执行 jQuery
?
我在下面尝试过,但不起作用。
jQuery(document).ready(function(){
parent.jQuery("#showcasef", jQuery.browser.msie ? parent.jQuery('body')[0] : parent.jQuery(document)).live('submit', function(e) {
e.preventDefault();
return false;
var pho_id = jQuery('#pho_id').attr('value');
var showcase =jQuery("#showcase_pho option:selected").val();
var action = "showcasep";
alert("here");
}
);
});
最佳答案
您需要在该 iframe
中再次包含 jQuery,或者尝试...
parent.$('body').text('Does it work?');
或者如果太长,可以制作一个包装器
function $() {
return parent.jQuery.call(this, arguments);
}
关于javascript - 从 Fancybox iframe 调用 jQuery?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3902774/