<! Doctype html> <html> <éadf> <meta http-equiv = "contenu-type" contenu = "text / html; charset = utf-8" /> <ititle> une instance javaScript par jour - supprimer le blanc à la fin de la chaîne </ title "); var Lines = input.value.split ("/ n"); var RUSTURSTRING = ""; for (var i = 0; i <line.length; i ++) {var string = lignes [i] .trim (); resultsTring + = String + "-"; } alert (résultats); } </ script> </ head> <body> <textArea id = "inputId" placeholder = "Veuillez entrer plusieurs lignes de chaîne"> </ textarea> <a href = "#" onclick = "white ()"> clickme </a> </ body> </html>Détecter les navigateurs de version inférieure, compatible en arrière:
if (typeof string.trim == "Undefined") string.prototype.trim = function () {return this.replace (/ (^ / s *) | (/ s * $) / g, ""); }}