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

steven schwerin
steven schwerin
7,722 Points

jQuery simple email plugin code challenge

i am getting kind of discouraged here. i keep missing pieces of key information, can't figure out what i am missing, get stuck and have to look at the Forum for help. Forums are not going to exist out in the big, bad world. How was I supposed to know to use "input" in 2/4 and "textarea" in 3/4 when all we have been doing is using selectors? is this something i am just supposed to accept and use as a foundation for future knowledge?

how am I supposed to take this? would appreciate any advice on the matter.

steve

6 Answers

James Barnett
James Barnett
39,199 Points

> . How was I supposed to know to use "input" in 2/4 and "textarea" in 3/4 when all we have been doing is using selectors?

The Build an Interactive Website project is marked as advanced because it assumes prior knowledge in HTML & CSS. That includes knowing what a text input field is and how to create one in HTML. A primary skill in programming is taking a requirement such as a use should be able to enter an email address and figure out exactly what code you need to write to do that. I hope that makes sense.

steven schwerin
steven schwerin
7,722 Points

Some of what you say is definitely helpful. The fact the stage assumes a certain amount of prior knowledge is a good thing to remember. i do know how to create a text input field in HTML thanks to you guys. Admittedly, i am still green behind the ears. Unless i am misunderstanding something, the examples we have been using have all used CSS selectors to manipulate elements. Am i wrong? It seems like we are using the element tag itself here. Sorry if these are gross mischaracterizations of what we are doing. i really am trying to learn, and it is all hurting my brain at the moment. I want to make sure I understand what we are doing before I move forward.

In the next code challenge, the way the <article> tag is used was confusing. I thought I was supposed to name the tags, '<article1>', '<article2>', '<article3>' vs. <article>1</article>, <article>2</article>... In the video, it seems like the tags are formatted like block elements vs how we are using them being more inlinish. Again, I may be really mischaracterizing this since I am still learning how to use these terms. I am going on the assumption that you want feedback like this. Yes, I am the idiot who breaks all idiot-proof systems. I am generally likable, though, and not complaining just to complain.

lastly, maybe going to the forum all the time to find the answers is the way I am supposed to learn until I can think for myself better. I am not discounting that option.

Thank you very much for the response.

steven schwerin
steven schwerin
7,722 Points

James,

As I move forward with learning programming, I am thinking of things in terms of building a foundation for future knowledge. Thanks for the reminder there. This reasoning is why I really want to know what the deal is with using ("input") and ("textarea"). I acknowledge that my question may be way out there; if so, I need it reigned in so as to build a better foundation for future knowledge. The way I see it is that if these words were CSS selectors, they would have a '.' in front of them and if they were IDs, they would have a '#' in front of them. We also could have been using them as variables, but then we would have been equating them to something when assigning them. Is my thinking off?

James Barnett
James Barnett
39,199 Points

> This reasoning is why I really want to know what the deal is with using ("input") and ("textarea").

Sound like you might need to go back to the basics of HTML. Input and textarea refer to 2 types of HTML form fields. Both CSS & JQuery work by using selectors to modify the appearance and behavior of a selected HTML element.

steven schwerin
steven schwerin
7,722 Points

Both CSS & JQuery work by using selectors to modify the appearance and behavior of a selected HTML element.

Thank you for the response. I may just have to go back to basic HTML. That is why I am trying to get my mind around what we are doing here in this example. If I missed something, then I want to know generally that I missed something in HTML so that I can go learn it. I do, however, know that textareas and inputs are basic HTML form elements. I did not know that we could use the element name to modify itself in jQuery; we had just been using CSS selectors to select the element to which we were applying jQuery.

So, we can actually just use the element name? So I could modify the link elements with $("a").FIT.WHATEVER.JQUERY.METHOD.YOU.WANT.HERE? I was under the impression that we needed to use either a class or an id of the link element, so $(".class") or $("#id"). I really don't think this is called out in the videos. Understandable. You can't call out everything, and I can be easily confused.

Regardless, I am going to review basic HTML and CSS. I feel like there was a lot I missed the first time around.

Thank you for baring with me.

James Barnett
James Barnett
39,199 Points

JQuery uses the same selectors CSS does.

If you wanted to make the text color of a button blue in CSS you'd do button {color: blue; }.

If you wanted to let's say toggle an input field to show/hide when you clicked a button using JQuery:

  • Q: What element going to receive the action?
  • A: The button
  • Q: What action is it going to receive?
  • A: A click
  • Q: What's going to happen when the button receives a click?
  • A: The input field is going to toggle

Now that we know all of that ...

  • Q: What elements are we selecting
  • A: The button & input. elements
  • Q: How would we select those in CSS?
  • A: If you just wanted to select every button & input element on the page, referencing the elements by type works fine, so using button & input.

So put that all together and you get this bit of JQuery:

$('button').click(function() {
  $('input').toggle();
});

Here's a working demo of that code available on codepen

steven schwerin
steven schwerin
7,722 Points

Thanks! I was thinking of jQuery selectors as just the class and id tags for some reason. I will think about your answer, but I think that knowing that jQuery and CSS use the same selectors will push me down the road a little further. 'Don't know why I didn't pick that up from the beginning.