質問する
1228 次
3 に答える
1
\ でエスケープできます
if (this.value == '') {
this.value = 'I\'d be happy to make this introduction if possible. Contact me at your convenience.';
}
于 2013-07-18T16:53:24.627 に答える
1
あなたに必要なのは
window.onload=function() {
var txtArea=document.getElementById("accept-response-text");
txtArea.onfocus=function() {
if (this.value === this.defaultValue) {
this.value = '';
}
}
txtArea.onblur=function() {
if (this.value === '') {
this.value = this.defaultValue;
}
}
}
アップデート
これは、プレースホルダー付きのバージョンで、プレースホルダーなしのブラウザーをサポートしています
function hasPlaceHolder() {
var i = document.createElement('input');
return 'placeholder' in i;
}
window.onload=function() {
var txt_area_accept = document.getElementById("accept-response-text");
if (!hasPlaceHolder()) {
txt_area_accept.defaultValue=txt_area_accept.getAttribute("placeholder");
txt_area_accept.onfocus = function() {
if (this.value === this.defaultValue) {
this.value = '';
}
}
txt_area_accept.onblur = function() {
if (this.value === '') {
this.value = this.defaultValue;
}
}
}
}
于 2013-07-18T16:59:36.707 に答える