Jump to content
Killersites Forums

event handlers part 2 consol.log error different to video


webmanz
 Share

Recommended Posts

Re Event Handlers part 2 from Chapter 2

 

The only consol error I couldn't replicate as per the video was the hover. In the video the consol log error appears as:

Something happened: 2nd p tag moused-over

Instead I get on Sublime text Firefox:

SyntaxError: identifier starts immediately after numeric literal 

 

My code looks like this:

<!DOCTYPE html>
<html onkeypress="sniffer('You pressed a key!')">
<head>

      <meta charset="UTF-8">
      <title> Ch2 Javscript</title>
    <script>
        function sniffer(message) {
            console.log("Something happened: "+ message);
        }

    </script>

    <style type="text/css">
        #secondP {width: 200px; background-color: #AFE6A5}
        p:hover, button:hover {cursor: pointer;}
</style>

</head>
<body onresize="sniffer('window resized')" onload="alert('page loading')">

    <h1>Welcome Uber Nerdling!</h1>

    <button id="butt"  type="button" onlcick="sniffer('Try it button clicked')">Try it</button>

    <p onclick="sniffer('p tage clicked')">&Lorem ipsum dolor sit amet, consectetur adipisicing elit. Quaerat neque quo inventore ipsam, eveniet obcaecati et possimus, quas sed dolores autem delectus expedita! Quis amet alias accusantium at debitis, tempora.</p>

    <p onmouseover="sniffer(2nd p tag moused-over')" id="secondP">&Lorem ipsum dolor sit amet, consectetur adipisicing elit. Possimus quod, voluptate dolor adipisci officia consequatur blanditiis nobis voluptatibus magni ipsum. Perspiciatis, autem? Suscipit quasi nam odio blanditiis, harum voluptate quidem.</p>
 

 

Edited by webmanz
Link to comment
Share on other sites

3 hours ago, webmanz said:

    <p onmouseover="sniffer(2nd p tag moused-over')" id="secondP">&Lorem ipsum dolor sit amet, consectetur adipisicing elit. Possimus quod, voluptate dolor adipisci officia consequatur blanditiis nobis voluptatibus magni ipsum. Perspiciatis, autem? Suscipit quasi nam odio blanditiis, harum voluptate quidem.</p>

.... Just glancing over your code, did you notice the missing single quote?

onmouseover="sniffer(2nd p tag moused-over')"

.. should be:

onmouseover="sniffer('2nd p tag moused-over')"

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

×
×
  • Create New...