javascript - 从 iframe 外部通过 CSS Path 访问元素

标签 javascript jquery html css iframe

我想通过 iframe 中的 CSS 路径访问 dom 元素。以下是直接的 CSS 路径:

var dompath = "html body div div div div div div div ul li a:contains('Parks')";

$(dompath).click(); 

如果我在没有 iframe 的情况下打开页面,上面的行工作正常。

我想在 iframe 中打开相同的页面,并希望从 iframe 外部触发对上述元素的点击。我已经尝试过这种方式,但它不起作用。

            $('#scaled_frame').contents().(domPath).click();        

如何从外部执行点击操作。

最好的问候,

最佳答案

试试这个:$('#scaled_frame').contents().find(domPath).click();

关于javascript - 从 iframe 外部通过 CSS Path 访问元素,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27167911/

相关文章:

jquery - 带有 slideDown 的下拉菜单,单击时更改菜单标题

javascript - jquery slideToggle 在 ContentPlaceHolder 中不起作用

javascript - CSS Transform Rotate 3D - 将鼠标悬停在卡片的每个 Angular 上

javascript - IE : onproperty change triggered when binding the handler by DOM element properties

javascript - 链接重定向到错误页面

javascript - pjax/ajax 和浏览器后退按钮问题

javascript - 如何将 JSON 内容放入 <ul> 标签并在 HTML 中形成

javascript - Div 内容在移动 View 中消失

javascript - 从/到 Javascript 字符串从 Go int64/uint64 序列化反序列化

javascript - 使用 Nodejs 创建命令行实用程序所需的输入