textarea에서 얻은 문자열 값을 focus() 및 blur(), 으로 전달하려고하지만 왜 [object object]를 얻을 것입니까? 매개 변수 전달 : 함수에 문자열 값 전달
나는 각 (성공적으로 각 텍스트 영역의 문자열 값을 얻을)와 나는 VAR에 문자열을 저장 - 그럼var value_default = $this.val();
내가이 var
$this.focus(function (value_default) {..})
에 전달 - 내가 잘못 전달 무엇입니까?
내가이 value_default
에 알리면 [object oject]가 표시됩니다. - 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는 다른 브라우저처럼하지 것이다 '상속'에 어떤 문제가 있는지?
이 경우'$ this.focus (function (value_default) {..})'실제로 함수에'value_default'를 전달하지 않습니다. 'value_default'가 첫 번째 인수 인 함수를 정의하고 있습니다 (이 경우 포커스 이벤트에서 전송 된 이벤트 객체가됩니다) – climbage