Jump to content
Killersites Community
webmanz

event handlers part 2 consol.log error different to video

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

Share this post


Link to post
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')"

Share this post


Link to post
Share on other sites
On 3/19/2018 at 6:22 PM, administrator said:

.... 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')"

That solved it Stef thanks

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now


×