Tim Rowland Tim Rowland - 10 days ago 7
HTML Question

HTML slider won't hide

I am trying to hide an html slider and submit button with jquery when the submit button is clicked. Unfortunately, my code isn't working and the slider and submit button are only momentarily hidden before they come back. I would really appreciate and help!

<form>
<input id="bet" type="range" min="0" max="100" value="0" step="1" onchange="showValue(this.value)" />
<input id="submit_bet" type="submit" value="Submit Bet!"/>
</form>

<span id="range">0</span>

<script type="text/javascript">
function showValue(newValue)
{
document.getElementById("range").innerHTML=newValue;
}
</script>

<script type="text/javascript">
$(document).ready(function(){
$("#submit_bet").click(function() {
$("#bet").hide();
$("#submit_bet").hide();
$("range").hide();
});
})
</script>

Answer

Maybe I understand your design...

If you just want to hide slider and submit button when you clicked, you can try:

<input id="submit_bet" type="button" value="Submit Bet!"/>

When you use type="submit" button, it will send form and refresh the page.

Comments