textarea から取得した文字列値を focus() と blur() に渡したいのですが、なぜ [object object] になるのでしょうか?
各 textarea の文字列値を each() で正常に取得し、文字列を var に格納します -var value_default = $this.val();
次に、これを渡しますvar
-$this.focus(function (value_default) {..})
間違って渡していますか?
これを警告value_default
すると、[object object] - alert(value_default); が表示されます。
あなたがそれを見る必要があるなら、以下はコード全体です...
$(".autohide").each(function(){
/* set the variable and store its value */
var $this = $(this);
var value_default = $this.val();
var parent_autohide = $this.parents('form');
var parent_button = $('input[type=submit]',parent_autohide).parents("div:.item-form").hide();
var parent_marginbottom = parseInt($this.parents("div:.item-form").css("marginBottom"));
$this.parents("div:.item-form").css({margin:'0px'});
alert(value_default); // I will get the string value of each textarea element
$this.focus(function (value_default) {
alert(value_default); // I will get [object object]
var $this = $(this);
$this.elastic();
$this.parents('div:.item-form').css({margin:'0px 0px '+parent_marginbottom+'px 0px'});
var $this_parent = $this.parents('form');
var $this_button = $('input[type=submit]',$this_parent).parents("div:.item-form").show();
}).blur(function(value_default){
alert(value_default); // I will get [object object]
var $this = $(this);
var value_current = $this.val();
if ( value_current == value_default)
{
$this.css({ height: 'inherit'});
$this.parents('div:.item-form').css({margin:'0px'});
var $this_parent = $this.parents('form');
var $this_button = $('input[type=submit]',$this_parent).parents("div:.item-form").hide();
}
});
});
どうもありがとう。
編集:
IEでエラーが発生した原因はわかっています-
$this.css({height: 'inherit'}); // this line will create error on IE
$this.css({height:''}); // IE likes this
では、IE が他のブラウザーのようにそれを受け入れないという「継承」の何が問題なのですか!??