以下是它的工作原理。在自然狀態下顯示一條消息。當用戶將注意力集中在textarea上時,消息就消失了。如果用戶的焦點超出了信息顯示的textarea。操作textarea值,以便在各種情況下顯示默認消息
我的問題是,我只希望在開始時顯示消息,並且當且僅當在文本字段中沒有用戶書寫文本時。即使用戶開始鍵入時,即使他沒有關注textarea,也不會顯示消息並且用戶文本仍然存在。如果用戶清除了textarea而不是消息顯示時的焦點。
我的問題是確保消息在用戶輸入一些信息後不顯示。
下面是我試過的。
$(function() {
// Initiate the textarea placeholder content
if($(".more").val() != '') {
var content = "Please provide any feedback from your experience or/and any features you would like to be added or removed.";
// Empty it's value upon select
$(".more").val(content);
}
$(".more").focus(function(event) {
// Erase text from inside textarea
if($(this).val() != '') {
$(".more").val('');
}
});
// Display the placeholder when the textarea is out of focus. Ensure that its empty.
$(".more").focusout(function(event) {
// Erase text from inside textarea
if($(this).val() == '') {
$(this).val("Please provide any feedback from your experience or/and any features you would like to be added or removed.");
}
});
});
佔位符沒有在這個意義上正常工作,這是不beingde顯示 –
你是什麼意思?這在過去5年的所有瀏覽器中都能正常工作。 –
@NielsKeurentjes:實際上_placeholder_上