$(".box_yazi2").each(function () {
var default_value = this.value;
$(this).css('color', '#555'); // this could be in the style sheet instead
$(this).focus(function () {
if (this.value == default_value) {
this.value = '';
$(this).css('color', '#000');
}
});
$(this).blur(function () {
if (this.value == '') {
$(this).css('color', '#555');
this.value = default_value;
}
});
});
This function of default value of input doesnt work in FF, but perfectly works in IE and ofcourse the input itself looks like this:
<input type="text" class="box_yazi2" id="konu" name="konu" value="Boş" />
You should use prop instead of so many functions to be honest, use 'delegate' instead of 'on' for late static binding.
I'm using the next code:
The solution is quite easy; you have an extra
});
in your code (thanks @ Box9).I would encourage you to reuse the variable and not create dozens of jQuery objects.
I've changed your example to
background-color
but it will work.demo
Use
this.defaultValue
Sorry for the link to w3notcools, http://www.w3schools.com/jsref/prop_text_defaultvalue.asp
Just use the
defaultValue
property:Or: