Check if value in input equals a certain value JQuery
jquery
Solution
You don't update the value of `enter` when you click so you only test the initial value which, of course, doesn't change.
Use this :
$('#enterButton').on("click", function() {
var enter = $('#enter').val();
if(enter == "Enter" || enter == "enter") {
$('.loader').fadeOut(2000);
}
});
Problem
``` var enter = $('#enter').attr('value'); $('#enterButton').on("click", function() { if(enter == "Enter" || enter == "enter") { $('.loader').fadeOut(2000); } }); ``` This is my code so far, I also tried using: ``` var enter = $('#enter').val(); ``` But still nothing worked, so can anyone help me fix this? Thanks :) EDIT: the html is: ``` <input id="enter" type="text" placeholder="Do what it says..."> <button class="btn" id="enterButton">Go!</button> ``` EDIT FINAL: The final answer is: ``` $('#enterButton').on("click", function() { var enter = $('#enter').val(); if(enter == "Enter" || enter == "enter") { $('.loader').fadeOut(2000); } }); ``` Because, the variable was outside, and was not updating with the button click :) Thanks @dystroy