Moderator: lauras
$('input').focus( function() {
$(this).val('');
});$('input').focus( function() {
if ($(this).val() == 'Nickname') {
$(this).val('');
}
});/* * * * * * * * * * * * * * * * * * * * * *
* Platzhalter-Feature
* basierend auf dem HTMl5-placeholder-attribute
*
* Leert alle Browser, die kein placeholder kennen, sich Ähnlich zu verhalten.
*
* @author: Dustin Breuer <breuer@lemm.de>
*
* @var where = Element
* @var placeholder = Wert der als Platzhalter gesetzt werden soll
* @var phColor = Farbe der Platzhaltercschrift
* @var fontColor = Eigentliche Schriftfarbe
*
*
* * * * * * * * * * * * * * * * * * * * */
function placeholder(where, placeholder, phColor, fontColor){
if(where.value == ""){
with(where){
value = placeholder;
style.fontStyle = "italic";
style.color = phColor;
}
}
where.onfocus = function(){
if(where.value == placeholder){
with(where){
value = "";
style.fontStyle = "normal";
style.color: fontColor
}
}
}
where.onblur = function(){
if(where.value == ""){
with(where){
value = placeholder;
style.fontStyle = "italic";
style.color: phColor;
}
}
}
}if(!("placeholder" in document.createElement("input"))){
placeholder(document.getElementById("myElement"), document.getElementById("myElement").getAttribute("placeholder"), "#555", "#333");
}<input type="text" name="blabla" placeholder="Ihr Name" />/* * * * * * * * * * * * * * * * * * * * * *
* Platzhalter-Feature
* basierend auf dem HTMl5-placeholder-attribute
*
* Leert alle Browser, die kein placeholder kennen, sich Ähnlich zu verhalten.
*
* @author: Dustin Breuer <breuer@lemm.de>
*
* @var where = Element
* @var placeholder = Wert der als Platzhalter gesetzt werden soll
* @var phColor = Farbe der Platzhaltercschrift
* @var fontColor = Eigentliche Schriftfarbe
*
*
* * * * * * * * * * * * * * * * * * * * */
function placeholder(where, placeholder, phColor, fontColor){
if(where.value == ""){
where.value = placeholder;
where.style.fontStyle = "italic";
where.style.color = phColor;
}
where.onfocus = function(){
if(where.value == placeholder){
where.value = "";
where.style.fontStyle = "normal";
where.style.color = fontColor
}
}
where.onblur = function(){
if(where.value == ""){
where.value = placeholder;
where.style.fontStyle = "italic";
where.style.color = phColor;
}
}
}
window.onload = function(){
placeholder(document.getElementById("myElement"), document.getElementById("myElement").getAttribute("pla"), "#555", "#333");
}
///////////////////
<input type="text" pla="asb" id="myElement" /> Mitglieder in diesem Forum: 0 Mitglieder und 1 Gast