hmav25 hmav25 - 1 year ago 67
Ajax Question

Replacing anchor tag text after it is clicked without removing css

I am changing anchor tag text once it is clicked using jquery (

) and it is working fine. But it also replaces the css of the anchor tag text.

Can anyone help me how not to replace css or add it again.

My html is as follows:

<div class="col-xs-12 col-md-12" >
<a class="btn btn-lg btn-success deal" target="_blank" style="width:100%;background:#b71c1c;" rel="nofollow, noindex"
href="<?= $coin["link"]; ?>" >
<b>Get Offer</b>

and code:

$(this).replaceWith("<?php echo $coin['coupon_code']; ?>");

Answer Source

If you just want to replace the content of the inner <b> tag, this is your best option:

   $(this).find('b').text('<?php echo $coin['coupon_code']; ?>');
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download