How do I go about making this button disappear after a user submits the vote?
<p id="button_<%= review.id %>"><%= f.submit "vote" %></p>
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
I’d disable the button instead of hiding; creates a less confusing interface.
You can do this most easily by just adding an
onclickattribute:But if you want to hide it, you can use
this.style.display='none';instead. (If I can remember vanilla JS)If you’re already using jQuery though (or are going to be doing a lot of stuff like this):
edit: this shows the difference between Dr.Dredel’s and my solution
onsubmitversion to make RobG happy (you have to put it on the<form>)He’s right that it makes more sense to do it
onsubmit; there are other ways to submit a form such as by pressing enter. Presumably you would still want to button to get disabled in such scenarios (which if I’m not mistaken will also prevent you from submitting twice via enter)edit: why yes, it does http://jsfiddle.net/mnbayazit/9Snna/2/