1
You don’t need to use jQuery for this. Use the method String.prototype.trim
, of Javascript itself.
For example:
const str = ' \n \n pix\n';
// Remove os espaços em branco.
const result = str.trim();
console.log({ str, result });
jQuery has the function $.trim
, that removes whitespace from the beginning and end of a string, as well as the method trim
of the JS. However, as we have seen above, since Javascript has natively method with this functionality, this function has been deprecated and is no longer encouraged by jQuery’s own authors.
In short, it would be enough to do:
$('input[name=opcaoPagamento]:checked')
.parent().text().trim();
Thank you very much, it went super well, thank you very friend! :)
– Caique