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 Introduction to jQuery DOM Manipulation Getters vs. Setters

Petar Karagenov
Petar Karagenov
8,608 Points

Question about one of the bonus goals for the pet website

I was trying to figure out how to disable the button when the checkbox is not checked, but now, when it gets checked, it gets blocked and can't be unchecked.

const $addPet = $("#add-pet");
const $terms = $("#terms");

$addPet.prop("disabled", true);

$terms.on("change", function() {
  if ($terms.prop("checked", true)) { 
    $addPet.prop("disabled", false);
  } else {
    $addPet.prop("disabled", true);
  }

});

1 Answer

Raphaël Seguin
seal-mask
.a{fill-rule:evenodd;}techdegree seal-36
Raphaël Seguin
Full Stack JavaScript Techdegree Graduate 29,228 Points

Hi, in your if statement, I think you want test the property "checked" of $terms, right ? So you need to use .prop() with only 1 argument in order to make it return a boolean : true or false.

if ($terms.prop("checked")) {
// ...
}
Did it help ?

cheers
Petar Karagenov
Petar Karagenov
8,608 Points

Yes, of course it helped! Thank you!