JavaScript: Remove the front and rear spaces of the string

xiaoxiao2021-03-06  63

By Ben

Method 1: Function KillSpace (x) {while (x.ley "== ') x = x.substring (1, x.ley); // while x.ley> 0) && (x.Charat (x.length-1) == ')) While (x.length> 0) x = x.substring (0, x.length-1); Alert (" Kill = " x " == ") Return X;} instance: var A = killspace (" abc "); // Depends on a ==" ABC "method 2: string.prototype.trim = function () { Return this.Replace (/ (^ / s ) | / s $ / g, "");} instance: var a = "abc" .trim (); // derived a == "abc"

转载请注明原文地址:https://www.9cbs.com/read-108242.html

New Post(0)