我想在一个html中绑定下面的脚本和表单代码我该怎么做?我认为当没有显示任何内容时,这段代码会给我一个空白值?
<form method="post" action="contactengine.php">
<input type="textbox" class="default-value" name="Name" id="Name" value="Full Name">
<input type="textbox" class="default-value" name="Email" id="Email" value="Email">
<input type="submit" name="submit" id="submit" value="Submit" class="submit-button" />
</form>
和
$('.default-value').each(function() {
var default_value = $(this).val();
$(this).css('color', '#746F66'); // this could be in the style sheet instead
$(this).focus(function() {
if(this.value == default_value) {
this.value = '';
$(this).css('color', 'black');
}
});
$(this).blur(function() {
if(this.value == '') {
$(this).css('color', '#746F66');
this.value = default_value;
}
});
});