Merhaba, her tıklamada küçülme ve büyüyen alternatif olacak bir şey yaratmaya çalışıyorum, ancak web sitem için jQuery 1.9
kullanıyorum. .toggle(function,function)
işlevi jQuery 1.9
'dan kaldırıldı, bunun yerine ne kullanmam gerektiğinden emin değilim.jQuery 1.9 kaldırıldı .toggle (işlev, işlev) sonra kullanım alternatifi nedir?
Herhangi bir yardım harika olurdu. http://jsfiddle.net/TNAC6/
yeni jsfiddle (jquery 1.9): http://jsfiddle.net/TNAC6/1/ İşte
kodum ben toggle yapmaya çalışıyorum olduğunu
Teşekkür
jsfiddle (eski kod, jquery 1.8 sürümü kullanır). Temelde geçiş yaptığım şey bir daire div.
(function($){
$.fn.createToggle = function(size) {
var ele = $(this);
var oldSize = ele.width();
console.log("creating new toggle on element: " + ele + " old: " + oldSize + " new: " + size);
console.log("its content is" + ele.children(".content"));
var growfn = function() {
$(this).stop().animate({
'width': size+'px',
'height': size+'px',
'margin-left': '-'+(size/2)+'px',
'margin-top': '-'+(size/2)+'px'
}, 500);
$(this).children(".content").toggle();
};
var shrinkfn = function() {
$(this).stop().animate({
'width': oldSize+'px',
'height': oldSize+'px',
'margin-left': '-'+(oldSize/2)+'px',
'margin-top': '-'+(oldSize/2)+'px'
}, 500);
$(this).children(".content").toggle();
};
ele.click(function() {
//insert code to toggle stuff
});
};
})(jQuery);
$(".home").createToggle(500);
ve css:
.circleBase {
-webkit-border-radius: 999px;
-moz-border-radius: 999px;
border-radius: 999px;
behavior: url(PIE.htc);
}
.home {
width: 200px;
height: 200px;
background: #FF5032;
position: absolute;
top: 300px;
left: 300px;
margin-left: -100px;
margin-top: -100px;
}
.title {
position: relative;
padding-top: 10%;
text-align: center;
font-weight: bold;
font-size: 24px;
}
.content {
text-align: center;
display: none;
}
ve html: iki devlet ile
<div class="circleBase home">
<p class="title">Glen Takahashi<p>
<p class="content">THIS IS CONTENT<BR> THIS IS CONTENT<BR> THIS IS CONTENT<BR> THIS IS CONTENT<BR> THIS IS CONTENT</p>
</div>
Birkaç yedek yöntemlerine
http://jsfiddle.net/TNAC6/2/ burada bulunabilir: https: //forum.jquery .com/topic/beginner-function-toggle-kullanımdan kaldırılmış-ne-use-use-bunun yerine, eğer kodunuzu gönderirseniz, doğrudan durumunuzla ilgili olarak size yardımcı olabiliriz. İlk etapta .toggle yöntemine hiç gerek duymadıkça. –
da jQuery UI kitaplığında bir .toggle() yöntemi var http://api.jqueryui.com/toggle/ – samazi
tamam kodumu ekledim, bu sizin için daha kolaysa –