我有一个HTML页面,其中包含一个动态生成的子HTML。我想更改几个子HTML元素的样式,但我无法访问任何子HTML元素
<!DOCTYPE html>
<html lang="en">
<head>
link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap-theme.min.css">
<link rel="stylesheet" href="new.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/js/bootstrap.min.js"></script>
<body>
<iframe id="cartoonVideo" src="http://www.youtube.com/embed/ABCDEFGH" frameborder="0" allowfullscreen></iframe>
**Child html gets generated here**
#document
<!DOCTYPE HTML>
<head>
link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap-theme.min.css">
<link rel="stylesheet" href="new.css">
</head>
<body>
<div class="access"></div>
</body>
</html>
</body>
</html>
如何访问具有类访问权限的子HTML div。通过CSS或任何JavaScript或JQuery方法?
答案 0 :(得分:0)
使用函数内容()返回iframe中的html内容
$("#cartoonVideo").contents().find('.access')