大佬教程收集整理的这篇文章主要介绍了在jQuery 1.9删除.toggle(function,function)之后,可以使用什么替代方法?,大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
通过两种状态,您可以将当前的切换状态保持为布尔值(我使用clickState
)。如果要具有多个状态,则可以继续向状态计数加1,然后检查总计数的模数,以确定应根据状态触发哪个函数。
我更新了您的代码,因为ele
实际上是您要使用的jquery对象
嗨,我正在尝试创建一些将在每次点击时交替缩小和增长的方法,但是我正在jQuery
1.9
为我的网站使用。该.toggle(function,function)
函数已从中删除jQuery 1.9
,因此我不确定要使用什么功能。
任何帮助都会很棒。
谢谢
这是我想进行切换的代码。基本上,我要切换的是一个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);
和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;
}
和html:
<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>
以上是大佬教程为你收集整理的在jQuery 1.9删除.toggle(function,function)之后,可以使用什么替代方法?全部内容,希望文章能够帮你解决在jQuery 1.9删除.toggle(function,function)之后,可以使用什么替代方法?所遇到的程序开发问题。
如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。
本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。