hmav25 hmav25 - 1 month ago 3x
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']; ?>");


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']; ?>');