Ver Mensaje Individual
  #5 (permalink)  
Antiguo 10/01/2010, 08:13
Avatar de junihh
junihh
 
Fecha de Ingreso: febrero-2004
Ubicación: República Dominicana
Mensajes: 997
Antigüedad: 20 años, 3 meses
Puntos: 7
Respuesta: Aplicar una funcion a un objeto creado dinamicamente

Hola señores

De todos modos preferi dividir la funcion y aplicarla con eventos directamente al objeto de esta forma:

Código HTML:
function tooltipOverThis (obj)
{
    var ob = document.getElementById(obj.id);
    //
    var tit = ob.title;
    window.tempObjTitle = tit;
    ob.removeAttribute ('title');
    //
    var tt = document.createElement ('div');
    tt.style.backgroundColor = '#000';
    tt.style.fontFamily = 'Helvetica, Arial, sans-serif';
    tt.style.fontSize = '10px';
    tt.style.color = '#FFF';
    tt.style.border = 'solid 1px #FFF';
    tt.style.padding = '6px';
    tt.style.position = 'absolute';
    tt.style.display = 'none';
    tt.id = 'lyrtooltip';
    tt.innerHTML = tit;
    document.body.appendChild (tt);
    tt.style.zoom = 1;
    //
    document.onmousemove = function (evt)
    {
	   tt.style.left = ( parseInt (mouseX(evt)) + 15 ) + 'px';
	   tt.style.top = ( parseInt (mouseY(evt)) - 5 ) + 'px';
	   tt.style.display = 'block';
    }
}
function tooltipOutThis (obj)
{
    document.getElementById(obj.id).title = window.tempObjTitle;
    //
    var tt = document.getElementById('lyrtooltip');
    tt.style.display = 'none';
    document.body.removeChild (tt);
    document.onmousemove = null;
}
Código HTML:
<div title="El titulo con ID" id="este" onmouseover="tooltipOver(this);" onmouseout="tooltipOut(this);">Esto es un div con title y ID</div> 
__________________
JuniHH
- Mi blog
- Mi portafolio

Última edición por junihh; 10/01/2010 a las 08:24