このテキストフィールドにmysqlエコーがある場合、どのようにjqueryヒントを上書きするのですか? 現在、私はjqueryのヒントを持っていますが、フィールドにmysqlの値があり、それをエコーしたときにjqueryのヒントが表示されています。mysqlでjqueryヒントをオーバーライドする方法echo
PHP jqueryのヒントスクリプト
$(document).ready(function() {
//Shows the title in the text box, and removes it when modifying it
$('input[title]').each(function (i) {
$(this).val($(this).attr('title')).addClass('hint');
$(this).focus(function() {
if ($(this).val() == $(this).attr('title')) {
$(this).val('').removeClass('hint');
}
});
$(this).blur(function() {
if ($(this).val() == '') {
$(this).val($(this).attr('title')).addClass('hint');
}
});
});
//Clear input hints on form submit
$('form').submit(function() {
$('input.hint').val('');
return true;
});
});
フォームのテキストフィールド
<input type="text" name="name" id="name" title="insert here" value=<?php echo $row3['name']?> />
**コードをインデントする必要があります。それ以外に、 'placeholder'属性を使わない理由はありますか?現代のすべてのブラウザでサポートされています。古いブラウザでは、動作させるためにhttps://github.com/mathiasbynens/jquery-placeholderがあります。 – ThiefMaster