Нужна функция убирающая пробелы с лева и с права.
$.trim() не работает!
function trim(s){
return s.replace(/^\s+|\s+$/ig,'');
}
function trimLeft(s){
return s.replace(/^\s+/, '');
}
function trimRight(s){
return s.replace(/\s+$/,'');
}
function my_trim(str){
str=str.replace(/^\s+/,'');
str=str.replace(/\s+$/,'');
return str;
}
function trim(s){
return s.replace(/^\s+|\s+$/ig,'');
}
$(function(){
/*function my_trim(str){
str=str.replace(/^\s+/,'');
str=str.replace(/\s+$/,'');
return str;
}*/
function my_trim(s){
return $.trim(s);
}
$("div.send_msg").click(function(){
text_msg=$("div.msg_text").html();
alert($.trim(text_msg));
$("div.msg_text").html($.trim(text_msg));
});
});
$(function(){
/*function my_trim(str){
str=str.replace(/^\s+/,'');
str=str.replace(/\s+$/,'');
return str;
}*/
function my_trim(s){
return $.trim(s);
}
$("div.send_msg").click(function(){
text_msg=$("div.msg_text").html();
alert($.trim(text_msg));
$("div.msg_text").html($.trim(text_msg));
});
});
$("div.send_msg").click(function(){
text_msg=document.getElementById("msg_text");
trimmed=$.trim(text_msg.value);
alert(trimmed);
text_msg.value=trimmed;
});
Цитата (Zzepish @ 11.01.2013 - 23:12) |
Запахало только таким боком |
$("div.msg_text")
$("#msg_text")