简体   繁体   中英

trim text inside anchor tag jquery

This is my anchor tag.

<a href="../checkout/orderdetails" id="checkoutButton" type="button" class="visible-xs-block btn btn-primary btn-block text-center btn-danger">Proceed to
                                    checkout
                                </a>

I tried to trim this like:-

$("#checkoutButton").text().trim()

But it's still not showing properly. I want the text to be like:_ 'Proceed to Checkout'

You're retrieving the text, not setting it.

let trimmed = $("#checkoutButton").text().trim();
$("#checkoutButton").text(trimmed);

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM