If a user clicks on a tag, right now it recognizes the full text (numbers and characters).
returns Popular Tag %82
I've tried:
$tag.click(function(){
var $this = $(this);
var text = $this.text();
var num = text.parseInt();
num.remove();
alert(text)
});
Doesn't do the trick for numbers. So how would I get just the letters? Ie: ignoring BOTH numbers and special characters(%)
Fiddle here! Thanks for you help!
The simplest way is to use a regex:
var s = "ABCblahFoo$%^3l";
var letters = s.replace(/[^A-Za-z]+/g, '');
[]
represents a character (or a number of different possible characters) ^
means all characters EXCEPT the ones defined in the brackets AZ
equals capital letters az
equals lowercase letters So... Replace every character that is NOT a letter with the empty string.
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.