Javascript 从外部标记访问没有类或id的内部标记数据
这是我的html:Javascript 从外部标记访问没有类或id的内部标记数据,javascript,jquery,Javascript,Jquery,这是我的html: <iframe id="edit-resp398__ifr" frameborder="0" src="javascript:"""> <!DOCTYPE > <html> <head xmlns="http://www.w3.org/1999/xhtml"> <body id="tinymce" class="mceContentBody " spellcheck="false" dir="ltr"> <p
<iframe id="edit-resp398__ifr" frameborder="0" src="javascript:""">
<!DOCTYPE >
<html>
<head xmlns="http://www.w3.org/1999/xhtml">
<body id="tinymce" class="mceContentBody " spellcheck="false" dir="ltr">
<p>I want to Access this</p>
<p>And also this..</p>
</body>
</html>
</iframe>
我想访问这个
还有这个
我只有一个iframe的id,这对于所有iframe都是不同的,所有iframe的id和body类都是相同的。我想使用iframe id访问特定文本区域中的材料。简而言之,我想使用iframe id访问iframe的主体。。如何使用jquery实现这一点?您可以尝试以下方法
$('#edit-resp398__ifr').find('p:first').text()
有关jQuery选择器的更多信息,请参见此处如果iframe的内容来自同一域,您可以通过以下方式访问它:
$('#edit-resp398__ifr').contents().find(selector)...