OnClick function and getting element by ID in javascript

Sharing buttons:

hello intern citizens and welcome to

JavaScript training bus labelled IT

studio now let's quickly work on two

main topics of JavaScript that is my

function and dot get element IV now

JavaScript revolves around these two

things and JavaScript is mainly used to

replace HTML or to make it something

functioning by default all like keep it

running on again and again or let it be

an action button or something like that

so let's quickly work on these two

things that are my function and dot get

element ID now let me just open up

brackets and the preview of it now let's

work on to an HTML to a bit so let me

just initiate a paragraph and let me

just simply give a heading that this is

a 7th chapter and then let me just start

working on one of the best part of HTML

that is button to make it functioning so

let me just put a button and HTML so

let's say button on click now on click

is something which will be working make

sure it is not in capital ledger it is

all case sensitive right here now in

double code we are going to use my

function now this is the main part that

is my function we are going to define

the function later not at this moment of

time so we're going to keep it in null

and let me just end it right here so

let's give a name to this button and

let's just say as hit me and if we save

it then you can see that here is a

button which says hit me now the

important part is that I have given the

function right here this is so important

in JavaScript every time you are going

to give a function so that you can give

a call in JavaScript by this main

function so let's just start our script

and in script we are going to give a

call but we are forgetting one thing we

haven't given

and ID so that we can give a call so

this time we're going to change a

paragraph so we'll we'll be giving an ID

to paragraph so that we can work it by

calling it and JavaScript so let's give

demo as its ID of paragraph now let's

initiate write in JavaScript so as I've

told you the main part that is function

you're going to write every time like

this in JavaScript that function and my

function now I'm just calling function

according to JavaScript with it and then

I'm calling my function on click button

by this and it's not so we are going to

work here and my function now so you're

going to initiate it with blazes and let

me just write our first variable text

one which says let me just give you a

greeting like Hello and make sure you're

going to add strings so it should be in

double quotes and end it with semicolon

and let me just give another string so

that you can get an idea of how you can

just add a string to and let me just

change the text this time right here let

me just simply write here as Internet

citizens now the main part we are going

to add both of these strings so for that

we are simply going to write as variable

text 3 let's just change it to 2 of

forgetten to change it and equals now

we're going to add both of them so that

we can show them together so we are

something on a write text 1 plus text 2

and and it fit semicolon now the main

part starts the main JavaScript function

to make it running to get it into the

action so we are simply going to write

it as document dot get element ID now

you might be thinking that is it is so

complicated that G is small and then e B

and I are in capital now here is a

concept behind this that this is called

the camel case which means that first

letter is gonna be small and lists are

gonna be in capital letter

in JavaScript so there's not that

complicated and after that you're gonna

simply call what I have given the idea

to paragraph so that was demo and I'm

gonna write that same thing right here

and then I'm gonna write in our HTML

because it's going to change our HTML

and gotta show up something equals to

text 3 now 2x3 is something that we are

going to call here because we have added

variable takes 3 now here's a smaller

I'm gonna write here as equals 2 now

it's good to go now text 3 is something

that I'm gonna call which is a simple

greeting which says hello internet

citizens and that's it if I click on

save and then if we click on hit me then

you can see that it is right in here as

hello Internet citizens now that's how

you blink JavaScript into the action now

also we are going to work on it in all

kinds of operators we are going to just

make JavaScript into the action just

like this button in all the operators

that will that you'll be reading from

the next section now you need to

remember these two things in JavaScript

you should learn this in syntax it's

gonna stay same forever like my function

then you're going to call my function to

null and then finally you're going to

get the document get element ID and then

you're going to simply say is in our

HTML equals to text 3 it could be like

anything into alert Script or it could

be anything so that is the main use of

JavaScript it brings the hidden part of

HTML into the action if you hit on

button or alert or maybe by default

that's all for this video thank you so

much for watching