Ciodensky Posted November 4, 2021 Share Posted November 4, 2021 Site URL: https://www.xystema.com/ Hi! I have a script below to change the text inside a block: <script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.5.0/jquery.min.js"></script> <script> $(document).ready(function() { $(".product-price").html(function() { return $(this).html().replace(".00", " /mo"); }); }); </script> I am wondering if there is a way for this to incorporate the changing of the font style. I want the " /mo" to change the font-size and font-color. I will appreciate any help here. Many thanks. Link to comment
creedon Posted November 4, 2021 Share Posted November 4, 2021 If you change your replacement value from " /mo" to " <span>/mo</span>" you can then change the mo the way you want. You can of course add class, id or style attributes. Let us know how it goes. Find my contributions useful? Please like, upvote, mark my answer as the best ( solution ), and see my profile. Thanks for your support! I am a Squarespace ( and other technological things ) consultant open for new projects. Link to comment
Ciodensky Posted November 4, 2021 Author Share Posted November 4, 2021 55 minutes ago, creedon said: If you change your replacement value from " /mo" to " <span>/mo</span>" you can then change the mo the way you want. You can of course add class, id or style attributes. Let us know how it goes. It did not work. Here's the code after I replaced. Please let me know if I missed something somewhere. <script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.5.0/jquery.min.js"></script> <script> $(document).ready(function() { $(".product-price").html(function() { return $(this).html().replace(".00", "<span style="color:blue;font-weight:bold">/mo</span>"); }); }); </script> Link to comment
Solution creedon Posted November 4, 2021 Solution Share Posted November 4, 2021 "<span style="color:blue;font-weight:bold">/mo</span>" You can't have double double quotes without escaping the inner quotes. It should be... "<span style=\"color:blue;font-weight:bold\">/mo</span>" ...or... '<span style="color:blue;font-weight:bold">/mo</span>' Let us know how it goes. Ciodensky and tuanphan 2 Find my contributions useful? Please like, upvote, mark my answer as the best ( solution ), and see my profile. Thanks for your support! I am a Squarespace ( and other technological things ) consultant open for new projects. Link to comment
Ciodensky Posted November 4, 2021 Author Share Posted November 4, 2021 3 hours ago, creedon said: "<span style="color:blue;font-weight:bold">/mo</span>" You can't have double double quotes without escaping the inner quotes. It should be... "<span style=\"color:blue;font-weight:bold\">/mo</span>" ...or... '<span style="color:blue;font-weight:bold">/mo</span>' Let us know how it goes. Both works! Amazing! I can now control this text. Thanks so much @creedon creedon 1 Link to comment
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment