6
<div id="videos">
   <div id="channel_div" style="display: block;">
      <div style="color: rgb(0, 0, 0); font-family: Arial, Helvetica, sans-serif; font-size: 12px; width: 555px;" class="firstVideo">
      .. trimmed <table here> 

      </div>
      <div style="color: rgb(0, 0, 0); font-family: Arial, Helvetica, sans-serif; font-size: 12px; width: 555px;">
       .. trimmed <table here>
      </div>
   </div>
</div>

我有上面的片段,并且divchannel_div 里面的 s 来自 youtube,带有样式,宽度限制会破坏 UI。

如何使用 jquery 删除这些样式?

我尝试了这个问题的建议如下:

$('#channel_div div').removeAttr('style');

也试过这个:

$('#channel_div > div').removeAttr('style');

但这些都不起作用。我只想将我的宽度添加为 300 像素。

有人可以提供这方面的指导。

4

3 回答 3

2

您不能对来自远程域的 iframe 执行此操作。

但是,您可能可以使用 php 并在内部获取远程文件以删除服务器端的这些参数,或者甚至使用 jquery 通过加载该获取的文件并使其成为内部嵌入。

另外,如果只是宽度问题,您是否尝试添加 CSS 规则?

.firstVideo { max-width: 300px !important; } 

我在我的手机上,所以我现在真的无法确定。

于 2012-12-19T03:46:50.173 回答
0

嵌入的 youtube 视频将在 iframe 中,如下所示:

   <iframe width="570" height="321" 
           src="http://www.youtube.com/embed/L5ZGU1Qkx8?
           wmode=opaque&showinfo=0&autohide=1" frameborder="0"> 
    </iframe>

所以在这里你可以使用它自己的属性来设置高度和宽度。

于 2012-12-19T04:14:54.377 回答
0

我认为你可以在 iframe 中操作 html,试试这个:

$('#iframeID').contents().find('#someID').html();
于 2012-12-19T03:18:03.473 回答