jquery how to compare character string to end of other string
This question already has an answer here:
How about this?
if(a.substr(a.length - b.length).toLowerCase() == b.toLowerCase()) {
// b == last characters of a
}
If you need case sensitivity, just remove both .toLowerCase()
methods.
function endsWith(str, suffix) {
return str.indexOf(suffix, str.length - suffix.length) !== -1;
}
链接地址: http://www.djcxy.com/p/83888.html
上一篇: 从字符串JS中提取最后一个子字符串