I'd like to select all iframes on our site where the src contains go.pardot.com and then add a class called pardotIframe.
There could be multiple iframes on a page and most, but not all will contain go.pardot.com in the src. I'm hoping to use src because most iframes do not have a class or id attribute.
Here is an example of the iframe code:
<iframe src="https://go.pardot.com/l/43312/2017-02-21/67lkx6" type="text/html" frameborder="0" allowtransparency="true" style="border: 0px; overflow: hidden;" scrolling="no"></iframe
How would I do that using jQuery? Thanks!
Rory McCrossan
338k41 gold badges321 silver badges353 bronze badges
1 Answer 1
To achieve this you can use the Atrribute Contains selector to find the iframe by the URL in the src, then simply add a class to it:
$('iframe[src*="go.pardot.com"]').addClass('pardotIframe');
answered Aug 18, 2017 at 18:12
Rory McCrossan
338k41 gold badges321 silver badges353 bronze badges
Sign up to request clarification or add additional context in comments.
Comments
default