框架内元素的选择器(具有相同原点) [英] Selector for element inside a frame (with same origin)
本文介绍了框架内元素的选择器(具有相同原点)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个具有以下结构的网页:
I have a webpage with the following structure:
<html>
<head>...</head>
<frameset>
<frame name="frame1" src="/index.jsp"/>
<frame name="frame2" src="/blank.jsp"/>
</frameset>
</html>
index.jsp
包含:
<html>
<head>...</head>
<body>
... <div id="test">test is here</div> ...
</body>
</html>
我需要一个jQuery选择器来直接访问div#test
.到目前为止,我只能这样写:$(frames[0].document.body)
...或这样:$("frame[name='frame1']")
.但是我有一个模板,要求我在$("here only")
内编写选择器.所以我不能使用.find()
或其他功能.
I need a jQuery selector to directly access div#test
. So far I've only been able to write it like this: $(frames[0].document.body)
...or this: $("frame[name='frame1']")
. But I have a template which requires me to write my selector inside $("here only")
. So I can't use .find()
or other functions.
推荐答案
尝试:
$("div#test", $("#someIFrame").contents())
这篇关于框架内元素的选择器(具有相同原点)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文