0

I have an ordinary table in html in an iframe and I would like to access it from the parent page (yes they are on the domain and server) I've tried every kind of:

$("#Iframe").contents().find("#mytable td");

I don't have the impression it detects my table cell or table at all. I would like indeed to do an event on it.

       $("#mytable td")         
        .mousedown(function () 
        {
            isMouseDown = true;
            $(this).toggleClass("highlighted");
            isHighlighted = $(this).hasClass("highlighted");
            return false;
        })
        .mouseover(function () {
          if (isMouseDown) {
            $(this).toggleClass("highlighted", isHighlighted);
          }
        })

This event works perfectly on a single page with the css style linked but how should I do it when using an iframe? What's the correct sentence to detect my table in the iframe?

4

1 回答 1

0

确保选择器 #Iframe 实际上作为 ID 在您的 iframe 元素上。

然后你可以在你的javascript中设置这样的东西......

var mframe = $('#Iframe').contents();
var mtable = mframe.find('#mytable td');

然后用mtable进城,都在一个 $(window).load(function(){...}

于 2013-05-09T14:02:43.237 回答