Moving left right with jQuery
I am jQuery beginner :) I am trying to move from left to right but all I did is moving to the right. How to move it back?
$(function () {
$('#box').click(function () {
$(this).animate({
"left" : "300px"
}, 开发者_JS百科4000);
});
});
Also I have update panel on my page with left right button that do some things in code behind. How to call this left/right function from code behind?
To move it back to the left you just append another animate:
$(function () {
$('#box').click(function () {
$(this).animate({
"left" : "300px"
}, 4000).animate({
"left" : "0px"
}, 4000);
});
});
This is an anonymous function as event handler you can't call, it will only run on the click events on the div. You could move it outside
$(function () {
$('#box').click(boxAnimation);
});
function boxAnimation() {
$(this).animate({
"left" : "300px"
}, 4000).animate({
"left" : "0px"
}, 4000);
}
and then maybe this will help.
EDIT:
I found an article describing how you can call javascript from the code-behind.
Hope it helps
精彩评论