Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/410.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何更新高度jquery/javascript?_Javascript_Jquery_Html_Css - Fatal编程技术网

如何更新高度jquery/javascript?

如何更新高度jquery/javascript?,javascript,jquery,html,css,Javascript,Jquery,Html,Css,我有嵌入代码,嵌入代码的原始高度为300px,但几秒钟后,它会根据我使用的参数随机更改其高度 这是代码(网页就是一个示例) $().attr(“src”http://www.bbs.com") .attr('id','bbs_-embed') .attr('width',1440) .attr('height',300) .附件(“正文”) ; 大约7秒后,高度变为1500px或更高(随机) 如何使用javascript/Jquery更新其高度(从300到新高度)?试试这个 $(documen

我有嵌入代码,嵌入代码的原始高度为300px,但几秒钟后,它会根据我使用的参数随机更改其高度

这是代码(网页就是一个示例)

$().attr(“src”http://www.bbs.com")
.attr('id','bbs_-embed')
.attr('width',1440)
.attr('height',300)
.附件(“正文”)
;
大约7秒后,高度变为1500px或更高(随机)

如何使用javascript/Jquery更新其高度(从300到新高度)?

试试这个

$(document).ready(function() {
       var ele = $( "<embed></embed>").attr("src", "URL")
                .attr('id', 'bbs_embed')
                .css({ "width": "1440px", "max-height": "300px", "overflow-y" : "scroll", "border":"1px solid black"});

                $("body").append(ele);
     });
$(文档).ready(函数(){
var ele=$(“”).attr(“src”,“URL”)
.attr('id','bbs_-embed')
.css({“宽度”:“1440px”,“最大高度”:“300px”,“溢出-y”:“滚动”,“边框”:“1px纯黑”});
$(“正文”)。附加(ele);
});

给它一个ID,调用该ID,更改高度。否则,您只是在不断地重新创建一个新的嵌入元素。我建议您使用,并在HTML上创建元素(如果需要,则隐藏),然后对其进行修改。为嵌入元素启用溢出滚动,并设置最大高度。如何获得新高度?@Jhecht在嵌入内容中我有一个ID,但它不会更新高度。这就像不从embed code.Hi读取id一样。这并没有让我达到高度:(我没有理解你的意思。高度是300px。它是否显示不正确?当页面开始加载时,高度是300px,10秒后嵌入代码的新高度是随机的,我需要更新到新高度,例如4000px。你明白我的意思吗?@MrPibe你能分享有问题的屏幕截图吗?想看看嵌入元素是否正确吗是扩张还是身体本身。
$(document).ready(function() {
       var ele = $( "<embed></embed>").attr("src", "URL")
                .attr('id', 'bbs_embed')
                .css({ "width": "1440px", "max-height": "300px", "overflow-y" : "scroll", "border":"1px solid black"});

                $("body").append(ele);
     });