jquery counter reset issue
I have the following code and even after a page refresh, the counter is
not getting a reset. Please help me out in resetting the "counter". Also
excuse me if there are any typo(s) or dirty coding.
<script type='text/javascript'>
$(window).load(function(){
$(document).ready(function() {
$('p').click(function() {
$(this).animate({
'color': 'rgb(' + (Math.floor(Math.random() * 256)) + ',' +
(Math.floor(Math.random() * 256)) + ',' +
(Math.floor(Math.random() * 256)) + ')'
}, 500);
});
$('#counter').data('count', 0);
$("#fl1").click(function() {
$('#counter').val(function(i, val) {
return val == '0' ? 1 : val + 1;
});
});
$('#counter').data('count', 0);
$("#fl2").click(function() {
$('#counter').val(function(i, val) {
return val == '0' ? 2 : val + 2;
});
});
});
});
</script>
</head>
<body>
<div id="fl1" style="float:left; margin: 20px 0 0 0; font-weight: bold;
display: inline; cursor: pointer;"><p>(1)</p></div>
<div id="fl2" style="float:left; margin: 20px 0 0 40px; font-weight:
bold; display: inline; cursor: pointer;"><p>(2)</p></div>
<br />
<form method=POST name="test" action="test.php">
<input type="hidden" name="counter" id="counter">
<input type="submit" value="Send" >
</form>
</body>
No comments:
Post a Comment