回答:
代わりにこれを試してください:
if($.trim($('#group_field').val()) != ''){
より詳しい情報:
val()jQueryオブジェクトを返さないため、連鎖はオプションではありません。trim()文字列に対してメソッドを呼び出していましたが、IEはを認識していませんString.trim。
次の$.trimようにを使用する必要があります。
if($.trim($('#group_field').val()) !='') {
// ...
}
別のオプションは、Stringそれが欠落している場合に備えてメソッドを直接定義することです:
if(typeof String.prototype.trim !== 'function') {
String.prototype.trim = function() {
//Your implementation here. Might be worth looking at perf comparison at
//http://blog.stevenlevithan.com/archives/faster-trim-javascript
//
//The most common one is perhaps this:
return this.replace(/^\s+|\s+$/g, '');
}
}
次にtrim、ブラウザに関係なく動作します:
var result = " trim me ".trim();