Let's talk about changing element attributes.
And I have a really good example lined up here.
So let's say we have an input element and we want to change this from text to password.
And so the idea here is we can write something like this,
but what if we wanted it to actually look more like this,
like password, password, password and stuff.
We can do that quite easily.
So let's go ahead and select this input.
Let's do const. Input is equal to and then just the input is the only one on the page.
So I don't have to worry about getting specific with it. And with the selector.
Then I can say the input dot ATTR,
that stands for attribute ATTR.
Do not text type.
And so let's console log this console dot log this type.
And this should say if we do it right text.
And let's bring that up. There it is.
Text error if we did 123123123.
Yep, same thing.
Cuckoo, cuckoo, Cool, cool.
But what if we wanted to change it?
So this is a lot like Val or text or HTML.
And what I'm saying here is dot val,
dot text, dot HTML.
It does one of two things.
Either you give it a parameter or you've set a parameter.
And so we're saying simply get the type attribute.
This is our parameter.
It's just getting the type here that, that matches that.
Now if we wanted to change that, we could,
we could say ATTR type and then change it to password.
And this is going to happen so fast
and sort of looks like it is going to happen behind the scenes.
But when i type like this,
after I refresh the page,
it's going to look like a password field like this.
Now what's kinda cool is if you want to see my password,
I can simply select input dot ATTR type,
and let's change it from a password field to a text field.
And you can see my password is in plain text now,
my password is also.
So that's how we get an attribute and that's how we set an attribute.
And just as a quick little reminder,
to get an attribute just takes one parameter just like that.
And if it has a second parameter is going to try to set that attribute.
In the next lesson, let's go ahead and start working with some Ajax stuff.
Ajax is really, really fun.
It's working with APIs.
We're getting into some good JavaScript here,
some real fun stuff,
more production level stuff,
more professional kind of JavaScript that you're going to be writing using jQuery.