Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/89.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
Javascript 如何从iframe标记中删除样式(不是在iframe内部,而是在标记内部)_Javascript_Jquery_Iframe - Fatal编程技术网

Javascript 如何从iframe标记中删除样式(不是在iframe内部,而是在标记内部)

Javascript 如何从iframe标记中删除样式(不是在iframe内部,而是在标记内部),javascript,jquery,iframe,Javascript,Jquery,Iframe,我服务器上的页面有多个ID不同的iframe标记。我添加了一个iframe标记以嵌入youtube视频。iframe标记有一个样式元素,该元素提供250宽和250高,由插件添加。我想删除添加到iframe中的此样式,以便youtube视频在iframe标记中显示此特定iframe的高度和宽度,因为页面上还有其他iframe标记具有不应触摸的样式 1) 我正在添加的代码(注意宽度=640高度=390) Javascript或Jquery会很好。但是jquery中的remove标记会从页面上的每个i

我服务器上的页面有多个ID不同的iframe标记。我添加了一个iframe标记以嵌入youtube视频。iframe标记有一个样式元素,该元素提供250宽和250高,由插件添加。我想删除添加到iframe中的此样式,以便youtube视频在iframe标记中显示此特定iframe的高度和宽度,因为页面上还有其他iframe标记具有不应触摸的样式

1) 我正在添加的代码(注意宽度=640高度=390)

Javascript或Jquery会很好。但是jquery中的remove标记会从页面上的每个iframe中剥离样式

理想的解决方案将导致只有带有
id=“player”
的iframe从上面的2)更改为不再具有
style=“”
或具有style=“”,但其中没有任何内容

$('#player').removeAttr('style')
应该可以使用最新的jQuery

作为解释

$('#player')
以id='player'作为DOM元素的目标(#以id为目标,如css选择器)

从目标对象中删除“样式”属性

Try with ,
For style change :
$("#player").css("Height","90");

For attribute change :
$("#player").attr("Height","90");

For inside of iframe tag attribute or style change :
$("#player div").attr("Height","90");
$("#player div").css("Height","90");
应该可以使用最新的jQuery

作为解释

$('#player')
以id='player'作为DOM元素的目标(#以id为目标,如css选择器)

从目标对象中删除“样式”属性

Try with ,
For style change :
$("#player").css("Height","90");

For attribute change :
$("#player").attr("Height","90");

For inside of iframe tag attribute or style change :
$("#player div").attr("Height","90");
$("#player div").css("Height","90");
$('#player').removeAttr('style');
试试这个

$('#player').removeAttr('style');

document.getElementById('player')。removeAttribute('style')

我认为您不应该使用jQuery或任何其他JS库


CSS解决方案:
#播放器{宽度:640px!重要;高度:390px!重要;}
但使用
!重要提示
是不好的做法。

document.getElementById('player')。removeAttribute('style')

我认为您不应该使用jQuery或任何其他JS库


CSS解决方案:
#播放器{宽度:640px!重要;高度:390px!重要;}
但使用
!重要提示
是不好的做法。

@DocKuro。。。速度更快,没看到。我也经常这样:)@DocKuro。。。我也经常这样:)这是不好的做法,但它完全有效:)这是不好的做法,但它完全有效:)