我遇到了麻烦,当我点击img或链接标签时,我的框必须最大化,当我再次点击同一按钮时,我必须最小化。听说我遇到了麻烦,有人能纠正我的问题吗?
- 当我点击hello按钮时,我的框必须最大化,当我点击返回时,它需要最小化
- 听说问题是当我开始点击事件时,两个按钮都会最大化
我找不到问题是
http://jsfiddle.net/Navya/eVUkG/1/
$(function() {
$( "#button" ).toggle(
function() {
$( "#effect" ).animate({
backgroundColor: "#0000",
width: 500,
}, 500 );
},
function() {
$( "#effect" ).animate({
backgroundColor: "#000",
width: 240
}, 500 );
}
);
});
首先,两个按钮的ID都为button。Id必须是唯一的。其次,不以.effect
为目标,只以按钮(演示)的父对象为目标
$(function() {
$("#container").sortable({
handle: 'h1',
scroll: false,
revert: true,
tolerance: 'pointer'
});
$(".button").toggle(function() {
$(this).parent().animate({
backgroundColor: "#0000",
width: 500,
}, 500);
}, function() {
$(this).parent().animate({
backgroundColor: "#000",
width: 40
}, 500);
});
});