ITeye博客

javascript at IE of trim problem

夜鸣猪 · 2013-03-06 04:02 · Ruby On Rails · 编程语言 · Markdown


var ID = document.getElementByID('rep_id').value.trim();

Message: Object doesn't support this property or method Line: 604 Char: 2 Code: 0 URI: http://test.localhost/test.js


if(typeof String.prototype.trim !== 'function') {
  String.prototype.trim = function() {
    return this.replace(/^\s+|\s+$/g, ''); 
  }
}

String.prototype.trim = function() {
    return this.replace(/^\s+|\s+$/g,"");
}
String.prototype.ltrim = function() {
    return this.replace(/^\s+/,"");
}
String.prototype.rtrim = function() {
    return this.replace(/\s+$/,"");
}

//Use Jquery
$.trim( $("#mycomment").val() );
if ($(this).val().trim() == "")
var originalValueTrimmed = $.trim($(this).val());              
            if (originalValueTrimmed  == "") { ... }




if($('#group_field').val().trim()!='')
//should be
if($.trim($('#group_field').val()) != ''){


评论(0)

暂无评论。

评论功能维护中,当前仅展示历史评论。