आप डॉन ' इसके लिए JQuery की आवश्यकता नहीं है।
function endsWith(s,c){
if(typeof s === "undefined") return false;
if(typeof c === "undefined") return false;
if(c.length === 0) return true;
if(s.length === 0) return false;
return (s.slice(-1) === c);
}
endsWith('test','/'); //false
endsWith('test',''); // true
endsWith('test/','/'); //true
तुम भी एक प्रोटोटाइप
String.prototype.endsWith = function(pattern) {
if(typeof pattern === "undefined") return false;
if(pattern.length === 0) return true;
if(this.length === 0) return false;
return (this.slice(-1) === pattern);
};
"test/".endsWith('/'); //true
jQuery ऐसा नहीं कर सकते लिख सकते हैं। हालांकि, जावास्क्रिप्ट कर सकते हैं। –
संभावित डुप्लिकेट [स्ट्रिंग के अंतिम अक्षर को कैसे प्राप्त करें?] (Http://stackoverflow.com/questions/3884632/how-to-get-the-last-character-of-a-string) –