0

here is my code

<!DOCTYPE html>
<html>
<link rel="stylesheet"
type="text/css"
href="style.css" />
<title>mysite</title>
<head>
<image src="images.jpg" id="img1">
<image src="images2.jpg" id="img2">
<script src="jquery.js">
</script>
<div id="div1">
<p id="p1"></p>
</div>
<script>
function namething() {var name = prompt("what is your name")
document.getElementById("p1").innerHTML = "<h1>welcome, " + name + "</h1>" };
//$("#button2").click(function()
function namething2() { alert("yes")
$("div").animate({ height: 0 /*left:"250px" , opacity:"0. 5", right:"500px" */})
});
</script>
<button id="button2" onclick="namething2()">animationtest</button>
<button id="button1" onclick="namething()">click me!</button>
</head>
<script>

</script>
<body>

<p id="animate1">
</p>

<p id="center">hello</p>
</body>
</html>

returning namething2 not defined? did i miss something? please dont ask what i am doing this is just things i am testing things i am not actually trying to do something

1
  • It looks like you've got some HTML in the <head> when it should be in the <body>. There are other errors as well, including unclosed tags, missing semicolons, etc. Be sure to check your javascript error console. Here's this: jsfiddle.net/Njbst Commented Jun 4, 2013 at 23:43

5 Answers 5

2

namething2 is not defined, because you have a syntax error in your JavaScript code. Look in the console for the error message, or use a syntax-checking editor such as the free Komodo Edit.

Komodo also includes a JavaScript beautifier that cleans up your formatting and indentation. With no indentation the way you have it in the question, it's very hard to visually notice errors like the one you have. Properly formatted and indented code makes it much easier to see problems like this.

If you load your entire HTML page into Komodo it will highlight all of the errors people have mentioned in the answers (except for the missing semicolons which are not really errors but recommended practice).

Sign up to request clarification or add additional context in comments.

2 Comments

Specifically, you've got an extra ); at the end of all your code, you're missing a ; after the alerts, and you have an extra ; after the first function (that last is not strictly a syntax error)
There's also a missing ; after the prompt(), but that's not a syntax error - nor is the one after the alert(). Automatic semicolon insertion takes care of those. But it is better to put in the semicolon. Anyway, I am hoping to equip OP with the tools to find these errors on their own. Otherwise what can they do? Ask on Stack Overflow every time there's a syntax error?
0

Checkout what character is right after the right curly-brace that closes namething2.

Comments

0

Is there a terminating brace missing at the end of the function?

   function namething2() { alert("yes")
    $("div").animate({ height: 0 /*left:"250px" , opacity:"0. 5", right:"500px" */})
    }); 
   }
  ^^^

Comments

0
  function namething2() { 
       alert("yes");
       $("div").animate({ height: 0 /*left:"250px" , opacity:"0. 5", right:"500px" */});
  }

Comments

0

From what I see you have 3 lines and 3 missing semicolons at the END after a complete statement:

namething #1:

    var name = prompt("what is your name");

namething #2:

    function namething2() { alert("yes"); 
    $("div").animate({ height: 0 /*left:"250px" , opacity:"0. 5", right:"500px" */});

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.