Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> Dynamicznie generowane zdarzenie
230005
post
Post #1





Grupa: Zarejestrowani
Postów: 316
Pomógł: 36
Dołączył: 2.04.2008

Ostrzeżenie: (0%)
-----


Chciałbym aby zdarzenie onmouseover było dodawana do każdego diva, ale funkcja oprogramowująca nie ma się wywoływać, dopóki (jak sama nazwa zdarzenia wskazuje (IMG:http://forum.php.pl/style_emoticons/default/winksmiley.jpg) ) myszka nie znajdzie się nad wybranym divem. Na razie mam coś takiego:

  1. <?php
  2. function Divs()
  3.    {
  4.        this.arrayOfDivs = new Array();
  5.        this.mainDiv = document.createElement('div');
  6.        this.mainDiv.className = 'otherDiv';
  7.        document.body.appendChild(this.mainDiv);
  8.  
  9.        for(var i = 0; i <= 2; ++i)
  10.        {
  11.            this.arrayOfDivs[i] = document.createElement('div');
  12.            this.arrayOfDivs[i].className = 'oneOfDivs'+i;
  13.            this.arrayOfDivs[i].setAttribute('onmouseover', this.putText(i));
  14.            this.mainDiv.appendChild(this.arrayOfDivs[i]);
  15.        }
  16.    }
  17.    
  18.    Divs.prototype.putText = function(smVar)
  19.    {
  20.        if(smVar == 0)
  21.            this.arrayOfDivs[0].innerHTML = &#092;"tekst\";
  22.        else if(smVar == 1)
  23.            this.arrayOfDivs[1].innerHTML = &#092;"tekst\";
  24.        else if(smVar == 2)
  25.            this.arrayOfDivs[2].innerHTML = &#092;"tekst\";
  26.    }
  27.    
  28.    window.onload = function ()
  29.    {
  30.      var oDiv = new Divs();
  31.    }
  32. ?>


Jak zrobić żeby działało? (IMG:http://forum.php.pl/style_emoticons/default/biggrin.gif)

Ten post edytował 230005 28.04.2009, 20:21:49
Go to the top of the page
+Quote Post
 
Start new topic
Odpowiedzi (1 - 1)
Crozin
post
Post #2





Grupa: Zarejestrowani
Postów: 6 476
Pomógł: 1306
Dołączył: 6.08.2006
Skąd: Kraków

Ostrzeżenie: (0%)
-----


Zdarzenia dodaje się poprzez element.addEventListener() (pogoogleaj sobie za wersją cross-browser bo IE daje ciała tutaj).
Go to the top of the page
+Quote Post

Reply to this topicStart new topic
2 Użytkowników czyta ten temat (2 Gości i 0 Anonimowych użytkowników)
0 Zarejestrowanych:

 



RSS Aktualny czas: 23.08.2025 - 17:48