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 trialTony Brackins
28,766 Pointsprop()
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
28,736 PointsFor 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.
Tony Brackins
28,766 PointsGotcha thx
Tony Brackins
28,766 PointsTony Brackins
28,766 PointsSo checkbox is a property or attribute?
geoffrey
28,736 Pointsgeoffrey
28,736 Pointscheckbox 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.