Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

General Discussion

Mia Allen
Mia Allen
2,929 Points

What am I doing wrong? HTML, CSS, and jQuery together. Seperate project.

I am writing a program that shows you how to make different slimes. What is wrong with my code?

<!DOCTYPE html> <html> <head>

<title>My Favorite Slimes</title> <meta charset="utf-8">

<style> h1 {text-align: center; color: black} body{font-family:fantasy; background-color:powderblue} img{ position: absolute; left: 700px; top: 150px; } #quiz-form{ position: absolute; left: 850px; top: 500px; } #result{ text-align:center; position:absolute; top: 600px; left: 900px;

 }

</style>

</head>

<body> <h1>My Favorite Slimes</h1> <img src="https://i.ytimg.com/vi/ftlbd-RHaIY/maxresdefault.jpg" width="500"> <form id="quiz-form"><select id='quiz-answer'><option>Fluffy Slime</option><option>Shampoo And Salt Slime</option></select><button type='submit'>Get The recipe!</button></form><div id='result'></div>

<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.4/jquery.min.js"></script> <script> $("#quiz-form").on("submit",function(event){event.preventDefault();var y = $("#quiz-answer");var o=y.val(); if (o==='Fluffy Slime'){$("#result").html("<em> Fluffy Slime <em> <br> You will need: <br> <ul> <li> Galette Shaving Cream <li> Elmer's School Glue <li> Contact Lens Solution <br> ")} if (o==='Shampoo And Salt Slime') {$("#result").text("try again.") $("img").attr("src","https://www.google.com/url?sa=i&rct=j&q=&esrc=s&source=images&cd=&ved=2ahUKEwjNlpGw7PvbAhUuq1kKHe9SASwQjRx6BAgBEAU&url=http%3A%2F%2Fwww.mp3.xyz%2Freal-shampoo-and-salt-slime-how-to-make-slime-with-only-shampoo-and-salt-no-borax-staejrd76-O.html&psig=AOvVaw2TmtYN9drnlVfZ7f04Ctan&ust=1530463867612526") }}) </script>

</body> </html>

1 Answer

Mia Allen
Mia Allen
2,929 Points

I solved It! Never Mind!