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

JavaScript jQuery Basics (2014) Creating a Password Confirmation Form Perfect

prop()

I'm having a problem understanding properties in HTML.

We have input element:

<input id="confirm_password" name="confirm_password" type="password">

What's the attributes vs properties of this input?

Thx

2 Answers

geoffrey
geoffrey
28,736 Points

For me attributes are properties of HTML elements...

If we check the JQuery documentation for the prop() method it says:

Get the value of a property for the first element in the set of matched elements or set one or more properties for every matched element.

With it, an example is given:

-HTML

<input id="check1" type="checkbox" checked="checked">

-JS

$( "input" ).change(function() {
  var $input = $( this );
 $input.prop( "checked" ); //returns true if It's checked, false, if not.

So yes, it looks like properties are attributes to me.

EDIT: to be sure of what I've told you, I've searched on google and I found this topic which confirms what I wrote with more details.

So checkbox is a property or attribute?

geoffrey
geoffrey
28,736 Points

checkbox is the value of the html property of type, or checkbox is the value of the attribute type, according things I've read, property is the same as attribute when talking of html elements.

Gotcha thx