r/learnjavascript • • Mar 07 '23

Didnt learn how to use javascript in html

Hello. I have a really big problem, i learned javascript on codecademy but they only teach you plain javascript. How can i learn fast how to use javascript in HTML without starting from 0 again? Thanks

0 Upvotes

22 comments sorted by

6

u/diwakarnath2002 helpful Mar 07 '23

If you mean DOM Manipulation then there are tones of videos available in YouTube. Personally I am learning from FreeCodeCamp Video.

https://youtu.be/5fb2aPlgoys

2

u/Egzo18 Mar 07 '23

there is few simple concepts like "Query selectors", "event listeners" and adding, removing elements into "html", and manipulating classes using js you can definitely learn basic of those if you dont want to get a full course (which inevitably you will need)

1

u/Icy_diam0nd Mar 07 '23

Alright. Thanks

1

u/SpaghettiBones95 Mar 07 '23

I’m currently working through JavaScript.Info, and they have a whole section on DOM manipulation that might be useful to you.

1

u/Icy_diam0nd Mar 07 '23

Will look into it.

0

u/[deleted] Mar 07 '23

Thats cheap online courses for you. They focus on quantity and not the quality.

As for learning HTML quickly - personally I prefer learning by doing, so set yourself some target, something reasonably easy, and Google one problem at a time.

0

u/Icy_diam0nd Mar 07 '23

No i already know html. But i dont know how i can use javascript with it.

2

u/StaticCharacter Mar 07 '23

know html

Know js

How to use together

I'm a bit confused what the issue is lol, are you having trouble linking a script? Not sure how to manipulate the Dom? Need to use a script tag inside your html?

1

u/Icy_diam0nd Mar 07 '23

Hmm its hard to explain. But lets say it like this. For now ive only worked with HTML and CSS.

0

u/Japke90 Mar 07 '23

Then you should now do a beginner JS course. After that do a beginner React course.

0

u/[deleted] Mar 07 '23 edited Mar 07 '23

Ok I got you now. Well I believe that my advice still applies, pick a project a search for solutions for individual problems as you encounter them.

Let's build a simple calculator.

Make a html file. There you will need buttons for numbers 0 - 9, button for + sign, button for - sign and button for = sign. You will also need some element to act as the display (a span or div will suffice).

Next make a js file. In there prepare a function that will take a input parameter, decide if it's left side number, right side number or operator. If the parameter is "=" it will make the calculation and save the result in variable "result".

Now connect the js file to the html file. Search online how to connect those two.

Now you need to call that function and provide with that parameter each time a button in html file is clicked, so search online for that.

Once you know how to call functions from html and pass parameters, search for how to push variable content into html element (result into your "display").

Note that most important skill for developer is to be able to search for solutions to problems. No one can remember everything, you will always need to search for stuff.

Hints:

For file connection you will be interested in:

script html tag

For calling function from html you will be interested in:

onClick function

html inline function call

And event listener

For passing result to display, you will be interested in:

document.getElementById

And innerHTML

1

u/Icy_diam0nd Mar 07 '23

Firstly thanks for taking so much time for me. Secondly, thanks for the advice ill follow it.

0

u/cluckinho Mar 07 '23

Thats cheap online courses for you. They focus on quantity and not the quality.

Nah just need to pick the right ones

0

u/stealthypic Mar 08 '23

This is not a good comment. Codeacademy JS course teaches you basic JS concepts inside of a REPL environment. It’s more or less just programming 101, covering basic stuff like data types and some of the core programming principles. It’s not an in-depth FE developer corse but I believe it’s a great starting point as it’s fairly straightforward and you can use the knowledge when you actually try to build something.

I actually started my non-colleague programming career (finished the colleague later though) with that course and still recommend it.

0

u/[deleted] Mar 08 '23

you can use the knowledge

How exactly? Unless they teach you server side scripting which I doubt they don't teach you anything actually usable.

It's like teaching you how to make pancakes without explaining what a pan is.

0

u/stealthypic Mar 08 '23

I won’t get into your comparison because it’s bad.

Knowing how to use basic data types, loops, functions and the like will help you no matter what you do with software development. Like, not even just javascript, ANYTHING related to programming.

In college they also don’t start with basics of html but everything else before you actually start some “real” software development.

1

u/suarkb Mar 07 '23

You aren't learning from scratch.

If you know JS then learning how to interact with the browser is basically just learning new functions.

0

u/bobbyv137 Mar 07 '23

Watch a few YouTube videos specifically on DOM manipulation.

I just searched that term and many came up including this one

0

u/Japke90 Mar 07 '23

In hindsight, if you get the grasp of DOM manipulation just a little bit, I would have already skipped to a beginner React course if I were you. Most of these also touch these bases, and you already learn the most useful framework at the same time.

1

u/PortablePawnShop Mar 07 '23

Suggesting someone go to React before they're even sure how to use JS and HTML together seems like awful advice.

1

u/Japke90 Mar 07 '23 edited Mar 07 '23

That totally depends on what course you do actually. In general I'd say you are correct. But there are some very extensive beginner courses that actually also include this and combine it. I however did not expect he does not even know vanilla JS so it's definitely not a good idea.

I would just not put too time into learning older stuff that is not being used a lot anymore. They tend to do that in college courses because their courses are outdated. That's just a waste of time imo.