Hi this the first project in jQuery i dont know what's wrong


#1

var main = function() {
$('#top-text').keyup(function(){
var toAdd = $("$top-text").val();
$('#top-caption').text();
});
$('#bottom-text').keyup(function(){
var toAdd = $("$bottom-text").val();
$('#bottom-caption').text();
});

}

$(document).ready(main);


#2

Hey Farouk,

So you've got two problems in your code:

  1. Lines 3 and 7, you need to be using a hash sign (#) instead of a dollar sign ($)
  2. Lines 4 and 8, you need to be using a dot (.) instead of a hash sign

Number one: $ is, in this case, the jQuery selector. We use it to select an HTML element. So, with line 3, you're trying to find an HTML element that looks like this:

<$top-text>

And no element like that exists :)
Then, number 2, dot vs hash sign vs nothing:

With the jQuery selector, we can select an HTML element multiple ways:

$('#id') // with its #id
$('.class') // with it's .class
$('tag') // with it's tag name

In the HTML, we've got this:

<h1 class="top-caption">U say something?</h1>
<h1 class="bottom-caption">I'm all ears</h1>

Since the captions don't have an #id, you need to use their .class to select them.

I hope this helps! Please let me know if you have any more questions or if you're still having trouble with your project :)