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 trialSági János
Courses Plus Student 6,185 PointsI dont understand
Hi Please send a solution i cant figure it out how to fix it. Thanks all
//Select the input for the title for blog post.
var $titleInput = $("#title");
//Select the preview h1 tag
var $previewTitle = $("#titlePreview");
// Every second update the preview
var previewTimer = setInterval(updatePreview, 1000);
function updatePreview(){
//Get the user's input
var titleValue;
//Set the user input as the preview title.
$previewTitle.text(titleValue);
}
<!DOCTYPE html>
<html>
<head>
<link rel="stylesheet" type="text/css" href="theme.css">
</head>
<body>
<div id="form">
<label for="title">Blog Post Title</label><input id="title" name="title" value="" placeholder="Enter your blog title here">
</div>
<div id="preview">
<h1 id="titlePreview"></h1>
</div>
<script src="//code.jquery.com/jquery-1.11.0.min.js" type="text/javascript" charset="utf-8"></script>
<script src="js/app.js" type="text/javascript" charset="utf-8"></script>
</body>
</html>
#form {
width: 45%;
float: left;
}
#preview {
width: 45%;
float: right;
}
label {
width: 20%;
display: inline-block;
}
input {
width: 70%;
}
2 Answers
Ryan Dudley
Treehouse Project ReviewerSorry for the late reply, but hopefully I can be of some help and get you on your way!
In order to solve this code challenge you need to retrieve the value from the input field ($titleInput
) and store the value within the titleValue
variable. The value then gets passed into the $previewTitle.text(titleValue)
method call.
So, in order to retrieve the value from our input with jQuery we can utilize the val()
method on our $titleInput
variable. So we would change the updatePreview()
function like so:
function updatePreview(){
//Get the user's input -- This is where we can use the val() method to get the input's value
var titleValue = $titleInput.val();
//Set the user input as the preview title.
$previewTitle.text(titleValue);
}
I hope this was able to solve your issue, and if you have any additional questions don't hesitate to ask!
Sági János
Courses Plus Student 6,185 PointsOh no problem! Thank you Ryan It's work finally. Great! Thanks everthing again. Okay I"ll dont be.
Steven Parker
231,269 PointsSteven Parker
231,269 PointsWithin an hour isn't "late". 3 days might be "late".