Hi,
I want to pass the string value which I get from the textarea into the focus() and blur(),
but why what I will get is [object object]?
I get the string value of each textarea successfully with each() and I store the string in a var -
`var value_default = $this.val();`
Then I pass this var
into
`$this.focus(function (value_default) {..})`
- am I passing it incorrectly?
If I alert this value_default
I will get [object oject] -
alert(value_default);
I know I can pass the parameter just like this,
.focus(function(){
and
.blur(function(){
but I will get ‘error on page’ on my IE7 with this. also I must not set the var to global bcos I have other textareas with different default text values…
Below is the entire code if you need to see it…
$(".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();
}
});
});
many thanks.