I am working on a wordpress plugin which allows a user to enter a image url and konami code. When the konami code is entered an image pops up, but I can't get it to animate, I am somewhat unfamiliar with jQuery and Javascript, and I am just starting to learn it... Any help would be fantastic!
<script type="text/javascript" charset="utf-8">
if ( wind开发者_Go百科ow.addEventListener ) {
var kkeys = [], konami = "{$this->opts['wpk_code']['current']}";
window.addEventListener("keydown", function(e){
kkeys.push( e.keyCode );
if ( kkeys.toString().indexOf( konami ) >= 0 ){
var elms=document.getElementById("konami").style;
elms.display=(elms.display=="block")?"none":"block";
}
}, true);
}
</script>
Have a play with some of the examples on jQuery's animate() - they seem to do what you want.
Try this:
$('#inputField').keyup(function () {
if ($(this).val().length > 0) {
$('#konami').animate({
opacity: 1,
left: '50'
}, 100);
}
else {
$('#konami').animate({
opacity: 0,
left: '0'
}, 100);
}
});
HTML:
<input type="text" id="inputField" />
<img src="..." id="konami" style="position:relative;" />
精彩评论