नमस्ते मैं कुछ ऐसा बनाने की कोशिश कर रहा हूं जो प्रत्येक क्लिक पर वैकल्पिक सिकुड़ने और बढ़ने लगे, लेकिन मैं अपनी वेबसाइट के लिए jQuery 1.9
का उपयोग कर रहा हूं। .toggle(function,function)
फ़ंक्शन jQuery 1.9
से हटा दिया गया था, इसलिए मुझे सच में यकीन नहीं है कि मुझे इसके बजाय क्या उपयोग करना चाहिए।jQuery 1.9 हटाए जाने के बाद उपयोग करने का विकल्प क्या है। टॉगल (फ़ंक्शन, फ़ंक्शन)?
कोई भी मदद महान होगी। http://jsfiddle.net/TNAC6/
नई jsfiddle (jQuery 1.9): http://jsfiddle.net/TNAC6/1/
यहाँ मेरी कोड मैं टॉगल बनाने के लिए कोशिश कर रहा हूँ है
धन्यवाद
jsfiddle (पुराने कोड, jQuery 1.8 संस्करण का उपयोग करता)। असल में जो चीज मैं टॉगलिंग कर रहा हूं वह एक सर्कल 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);
और सीएसएस:
.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>
कुछ प्रतिस्थापन तरीकों यहां पाया जा सकता है: https: //forum.jquery .com/topic/beginner-function-toggle-deprecated-what-to-use-इसके बजाए, यदि आप अपना कोड पोस्ट करते हैं, तो हम आपकी सीधी स्थिति के साथ आपकी मदद करने से अधिक कर सकते हैं। आपको पहले से कहीं भी .toggle विधि की आवश्यकता नहीं थी। –
jQuery UI लाइब्रेरी में एक .toggle() विधि भी है http://api.jqueryui.com/toggle/ – samazi
ठीक है मैंने अपना कोड जोड़ा है, अगर यह आपके लिए आसान बनाता है –