Предполагая, что вы хотите позвонить sani
, а не cleanStr
, вы можете сделать следующее:
function sani(str){
str = str.replace(/[^a-zA-Z ]/g, "");
return str;
}
$('button').click(function(){
var word = "<h1>Hello W<o>rld";
alert(word);
var result = sani(word);
//I need the following alert to be the string after sanitisation
alert("After sanitisation : " + result)
})