Solution 1 :

Those characters are tabs.

You can remove them by using spaces in your source or with trim()

$('a').on('click', function () {
    var name = $(this).text();
    alert(name);
    alert(name.trim());
 });
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<a href='#'>
			test
</a>

Problem :

I got the text of the tag in the alert, there are strange symbols near the text. Please tell me how can I remove these strange characters? I attach the program code and photo. Thank you.

 $('.blog_content_tags .tags li a').on('click', function () {
    var name = $(this).text();
    alert(name);
 });

enter image description here

Comments

Comment posted by Jeremy Thille

Could you please add the corresponding HTML? Currently this snippet does nothing

Comment posted by s.kuznetsov

they helped me solve the problem by the method – trim(). thanks

By

Leave a Reply

Your email address will not be published. Required fields are marked *