3

I have an iframecode . There is a [UID] word. I want that word to be replaced with my desired word.

<iframe class="ofrss" src="https://wall.superrewards.com/super/offers?h=asacgrgerger&uid=[UID]" frameborder="0" width="100%" height="550px"></iframe>

I want to pass the UID from jquery .

$("body:contains('UID')").html('15');

But this code doesn't give me the exact thing I want. It's not replacing the UID with 15

asked Oct 29, 2018 at 10:58

1 Answer 1

5

:contains looks within the text of the DOM, not attributes.

To do what you require you can use prop() or attr(), like this:

$('iframe.ofrss').prop('src', function(i, src) {
 return src.replace('[UID]', '15');
});

One thing to note here is that changing the src after the DOM loads will cause the iframe to be reloaded.

answered Oct 29, 2018 at 10:59
Sign up to request clarification or add additional context in comments.

1 Comment

Thank you so much.. You just saved my two days .. Thank you so much

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.