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 trialjames rochabrun
Courses Plus Student 22,726 PointsWhy does something like this wont work?
Hello to everyone caan someone tell me PLEASE, why something like this doesnt work? for disable the add button if there is not input value .
// a variable that returns true or false if the taskInput.value.lenght is <= than 0
function inputLength() { return taskInput.value.length <= 0; }
//a function that changes the property calling the inputLenghth function.
function disableButton() { addButton.disabled = inputLength(); }
// call the disableButton function
disableButton();
thank you very much
1 Answer
james rochabrun
Courses Plus Student 22,726 Pointsthanks for your answer i tried your function but still dont works , do you know why?
Bram Dijkhuis
5,746 PointsCan you paste some of your code in a codepen or post more of it here (especially the html).
Bram Dijkhuis
5,746 PointsBram Dijkhuis
5,746 PointsIt looks like your checking whether something is true or false without using any conditional statement. Why not use something like:
You might also want to expand this a bit by adding some code to check if (on keyup perhaps) the input has received a value and then enable the button, but I don't know if that's what you're looking for.