Monday, June 3, 2024
 Popular · Latest · Hot · Upcoming
97
rated 0 times [  99] [ 2]  / answers: 1 / hits: 28025  / 12 Years ago, tue, may 22, 2012, 12:00:00

I am not much of a JavaScript guru, so I would need help with a simple code.
I have a button that clears the value of an input field.



I would like it (the button) to be hidden if input field is empty and vice versa (visible if there is text inside the input field).



The solution can be pure JavaScript or jQuery, it doesn't matter. The simpler, the better.


More From » jquery

 Answers
2
if(!$('input').val()){
$('#button').hide();
}
else {
$('#button').show();
}


In it's simplest form ;)


[#85410] Monday, May 21, 2012, 12 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
leonardok

Total Points: 114
Total Questions: 94
Total Answers: 103

Location: France
Member since Thu, Oct 27, 2022
2 Years ago
;