Hello,
I have two pieces of javascript on my page. One of the javascript codes allows a person to place their cursor in a text field and the default writing in the text field will then disappear. Here is the code for this javascript:
The second piece of javascript that I am using on this page allows me to show and hide various information. Here is the script for this portion:
While the show/hide javascript works, the javascript that makes default text in a text field disappear does not work.
If you have some idea as to why the javascript isn't working please let me know! Thanks.
I have two pieces of javascript on my page. One of the javascript codes allows a person to place their cursor in a text field and the default writing in the text field will then disappear. Here is the code for this javascript:
Code:
<script>
var active_color = '#000'; // Colour of user provided text
var inactive_color = '#ccc'; // Colour of default text
$(document).ready(function() {
$("input.default-value").css("color", inactive_color);
var default_values = new Array();
$("input.default-value").focus(function() {
if (!default_values[this.id]) {
default_values[this.id] = this.value;
}
if (this.value == default_values[this.id]) {
this.value = '';
this.style.color = active_color;
}
$(this).blur(function() {
if (this.value == '') {
this.style.color = inactive_color;
this.value = default_values[this.id];
}
});
});
});
</script>
Code:
<script>
function doIt() {
$("#rankings").show("slow");
}
$("#button").click(doIt);
$("#button").click(function () {
$("#playerstats").hide(2000);
});
function doItAgain() {
$("#playerstats").show("slow");
}
$("#button1").click(doItAgain);
$("#button1").click(function () {
$("#rankings").hide(2000);
});
</script>
If you have some idea as to why the javascript isn't working please let me know! Thanks.
Comment