Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Unable to replace text Using Jquery

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

like image 840
Codecraker Avatar asked May 26 '26 15:05

Codecraker


1 Answers

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

like image 185
Rory McCrossan Avatar answered May 30 '26 03:05

Rory McCrossan



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!