www.webdeveloper.com
Results 1 to 4 of 4

Thread: EventListener does not work

Hybrid View

  1. #1
    Join Date
    Oct 2013
    Posts
    17

    Unhappy EventListener does not work

    Hello all,

    I wrote a little code with an EventListener, but it does not work. I think that the getElementbyId is wrong.
    Can you help me please?

    PHP Code:
            <script type="text/javascript">
                var 
    document.getElementById("h1");
                
    b.addEventListener("click",ausgabefalse);
                
                function 
    ausgabe(evt) {alert("Geschafft!");}
            
    </script> 

  2. #2
    Join Date
    Oct 2013
    Posts
    4
    <script type="text/javascript">
    var b = document.getElementById("h1");
    b.addEventListener("click",ausgabe(e), false);

    function ausgabe(evt) {alert("Geschafft!");}
    </script>

    you forgot the () after the function, i cant remember if u also have to parse a byval in the function when handling events tho, you'll have to experiment a little ^^

  3. #3
    Join Date
    Oct 2013
    Posts
    4
    PHP Code:
    <h1 id=h1>click here</h1>

    <
    script type="text/javascript">
      var 
    document.getElementById("h1");
      
    b.addEventListener("click",ausgabefalse);
                
      function 
    ausgabe(evt) {alert("Geschafft!");}
    </script> 

  4. #4
    Join Date
    Oct 2013
    Posts
    17
    I just change that. But it does not work.
    I wrote a same script in Jquery and this works.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center



Recent Articles