如何给iframe中的元素设置属性,如下图和代码
问题
如何给iframe中的元素设置属性,如下图和代码
<!DOCTYPE html><html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<meta http-equiv="X-UA-Compatible" content="ie=edge" />
<title>Document</title>
<script src="https://cdn.bootcss.com/jquery/3.4.1/jquery.min.js"></script>
</head>
<body>
<iframe id="iframe1" src="https://www.hao123.com/" frameborder="0"></iframe>
<script>
$(function() {
$("#iframe1")
.contents()
.find("body")
.attr("title", "aaaa");
});
</script>
</body>
</html>
回答:
<iframe src = "xxx" style = "width:100px height:100px"></iframe>
这是加宽度和高度的方法,其他属性也是这样,比如加个id
<iframe src = "xxx" style = "width:100px height:100px" id = "iframe1"></iframe>
再加个frameboredr,顺序随便改
<iframe src = "xxx" style = "width:100px height:100px" id = "iframe1" frameborder="0"></iframe>
以上是 如何给iframe中的元素设置属性,如下图和代码 的全部内容, 来源链接: utcz.com/a/161936.html