Cita:
Iniciado por Panino5001
En lugar de
elValor es mejor usar
Código:
document.getElementById(elemento).defaultValue;

Muy buena como siempre @Panino5001, nunca la había usado
Entonces nos quedaría
Código HTML:
Ver original<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"> <meta http-equiv="content-type" content="text/html; charset=utf-8" /> <script type="text/javascript"> //<![CDATA[
function fnc(elemento){
var valor = document.getElementById(elemento);
if(valor.value == valor.defaultValue){
valor.value = "";
}
}
//]]>
<input type="text" value="hola" id="nombre" onfocus="fnc(this.id)" /><br /> <input type="text" value="hola2" id="nombre2" onfocus="fnc(this.id)" /><br />
Saludos