I have inputfields that calculates and shows in an ! But when I want to go to the next page (to do a new calculation) my code only clears the inputfields and not the label where de result is shown. The code I have is shown down under..
<td>
<label class="o-money__totalsum" type="number" onfocus="this.value=''" step="1" name="total-<?php echo $counter;?>" id="total-<?php echo $counter;?>">0 SEK
</label>
</td>
function resetFields(){
$("o-exercise__button").click(function(){
$(".o-money__answer").val(''); <- my inputfields
$(".o-money__totalsum").val(''); <- the label!
});
}
Use .text()
to clear it , as mentioned in the comment .val()
is the value attributes, in the snippet below i used a onclick
event to trigger it
$(".o-exercise__button").on('click',function(){
$(".o-money__answer").val('');
$(".o-money__totalsum").text('');
});
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<td>
<label class="o-money__totalsum" type="number" onfocus="this.value=''" step="1" name="total-<?php echo $counter;?>" id="total-<?php echo $counter;?>">0 SEK
</label>
<button class="o-exercise__button">Click</button>
</td>
</div>