How to set fade timer in Jquery with HTML input?
I开发者_如何学运维 have a < div > That needs to fade in it will have a input box with the correct settings for timer. But i want to set it when it restarts so it fades in and out with that speed in js?
The $.fadeOut
and $.fadeIn
functions take a parameter of the duration for the fade animation. You can use the .val()
function on the input box and pass that as an attribute.
Example:
<div id="target" style="display:none;">Hello World!</div>
<input id="duration" value="1000" />
<button>Click To Show!</button>
<script type="text/javascript">
$(function () {
$('button').click(function(){
$('#target').fadeIn($('#duration').val());
});
});
</script>
var speed = $('#element').val();
$('#another-element').fadeIn('fast').delay(speed).fadeOut('fast');
精彩评论