JQUERY iFrame与警报一起工作,不';没有警觉就不能工作-奇怪吗?为什么?

JQUERY iFrame与警报一起工作,不';没有警觉就不能工作-奇怪吗?为什么?,jquery,iframe,binding,document-ready,Jquery,Iframe,Binding,Document Ready,以下内容在我的页面上不起作用: $("#bob").ready(function () { $("#bob").contents().find(".findme").css("background", "red"); $(document.getElementById('bob').contentWindow.document).find('.findme').bind("mousedown", function() { alert( $(this).text

以下内容在我的页面上不起作用:

$("#bob").ready(function () {
    $("#bob").contents().find(".findme").css("background", "red");

    $(document.getElementById('bob').contentWindow.document).find('.findme').bind("mousedown", function() {
        alert(  $(this).text() );
    });
});
但是,如果我添加了一个警报,我假设它会添加一些延迟,让iframe在JS继续之前运行,它会工作吗

$("#bob").ready(function () {
    alert(1)
    $("#bob").contents().find(".findme").css("background", "red");

    $(document.getElementById('bob').contentWindow.document).find('.findme').bind("mousedown", function() {
        alert(  $(this).text() );
    });
});
是延迟让它起作用了,准备好的人不应该处理这个吗?还有,有没有办法让上面的内容成为现实,这样时间安排就不成问题了?

试着把它放在一个

$(文档).ready(函数(){

而不是

$(“#bob”).ready(函数(){

请参见。如果使用
load
而不是
ready
,则该函数应该可以工作。