Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Remove css styles coming from embeded YouTube videos

<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>

I have above snippet and divs inside channel_div is coming from youtube with styles, with width constraints that breaks the UI.

How can i remove these styles with jquery?

I tried what this question suggested as follows:

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

also tried this:

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

but none of these worked. I just want to add my width as 300px.

Could someone please offer guidance on this.

like image 890
DarthVader Avatar asked Dec 19 '12 02:12

DarthVader


People also ask

How do I remove inline styling?

Given an HTML document containing inline and internal CSS and the task is to remove the inline CSS style from a particular element with the help of JavaScript. Approach: The jQuery attr() and removeAttr() methods are used to remove the inline style property. The attr() method sets the attribute value to empty (”).

How do you cancel a CSS style?

Use the style. removeProperty() method to remove CSS style properties from an element, e.g. box. style. removeProperty('background-color') .

How do I remove a class style?

Remove a class style from a selection Select the object or text you want to remove the style from. In the HTML Property inspector (Window > Properties), select None from the Class pop‑up menu.


1 Answers

You cannot do this with iframes from remote domains.

However, you can probably use php and fetch the remote file internally to remove those parameters server side, or even with jquery by loading that fetched file and make it an internal embed.

Also, if it's only a width issue, have you tried to add a CSS rule?

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

I'm on my mobile, so I really can't test it right now to be sure.

like image 144
BornKillaz Avatar answered Nov 10 '22 12:11

BornKillaz