1

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
asked Aug 18, 2017 at 18:06

1 Answer 1

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
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.