Check if value in input equals a certain value JQuery -


var enter = $('#enter').attr('value'); $('#enterbutton').on("click", function() {     if(enter == "enter" || enter == "enter") {         $('.loader').fadeout(2000);     } }); 

this code far, tried using:

var enter = $('#enter').val(); 

but still nothing worked, can me fix this? :)

edit: html is:

<input id="enter" type="text" placeholder="do 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, variable outside, , not updating button click :) @dystroy

you don't update value of enter when click test initial value which, of course, doesn't change.

use :

$('#enterbutton').on("click", function() {     var enter = $('#enter').val();     if(enter == "enter" || enter == "enter") {         $('.loader').fadeout(2000);     } }); 

Comments

Popular posts from this blog

html5 - What is breaking my page when printing? -

html - Unable to style the color of bullets in a list -

c# - must be a non-abstract type with a public parameterless constructor in redis -