$target.remove()
तत्व को हटा सकता है, लेकिन अब मैं कुछ महसूस एनीमेशन के साथ प्रक्रिया को कम करना चाहता हूं, इसे कैसे करें?jQuery के साथ धीरे-धीरे तत्व को कैसे निकालें?
उत्तर
$target.hide('slow');
या
$target.hide('slow', function(){ $target.remove(); });
एनीमेशन चलाने के लिए है, तो डोम
से हटानेtarget.fadeOut(300, function(){ $(this).remove();});
या
$('#target_id').fadeOut(300, function(){ $(this).remove();});
डुप्लिकेट: How to "fadeOut" & "remove" a div in jQuery?
आप
$target.hide('slow')
की तरह मतलब है?
से बेहतर काम करता है हां, लेकिन मुझे एनीमेशन के बाद इसे हटाने की भी आवश्यकता है। – Mask
यदि आपको छिपाने की आवश्यकता है और फिर तत्व को हटाएं तो विधि को छुपा विधि के कॉलबैक फ़ंक्शन के अंदर निकालें विधि का उपयोग करें।
यह काम करना चाहिए
$target.hide("slow", function(){ $(this).remove(); })
+1 उत्तर देने के लिए उत्तर के रूप में सही है। किसी भी तरह से मुझे '$ लक्ष्य' को दोहराने के बजाय '$ (this)' भी पसंद है। – goodeye
आप निकालना विधि कॉल करने से पहले एक एनीमेशन का उपयोग करने की जरूरत है।
देखें: jQuery slideUp().remove() doesn't seem to show the slideUp animation before remove occurs
$('#ur_id').slideUp("slow", function() { $('#ur_id').remove();});
मैं अपने मामले सूट करने के लिए ग्रेग के जवाब संशोधित कर लिया है, और यह काम करता है। यहां यह है:
$("#note-items").children('.active').hide('slow', function(){ $("#note-items").children('.active').remove(); });
सभी उत्तरों अच्छे हैं, लेकिन मुझे पता चला कि उनमें से सभी को उस पेशेवर "पॉलिश" की कमी है। मैं इस के साथ आया था, बाहर fading, ऊपर की ओर स्लाइड, तो को हटाने:
$target.fadeTo(1000, 0.01, function(){
$(this).slideUp(150, function() {
$(this).remove();
});
});
मैं पार्टी के लिए देर से थोड़ा हूँ, लेकिन मेरे जैसे किसी को भी है कि एक गूगल खोज से आया है और सही उत्तर नहीं मिलता के लिए । मुझे गलत मत करो वहाँ अच्छा जवाब यहाँ हैं, लेकिन वास्तव में क्या नहीं मैं आगे की हलचल के बिना, के लिए देख रहा था, यहाँ मैं क्या किया है:
$(document).ready(function() {
var $deleteButton = $('.deleteItem');
$deleteButton.on('click', function(event) {
event.preventDefault();
var $button = $(this);
if(confirm('Are you sure about this ?')) {
var $item = $button.closest('tr.item');
$item.addClass('removed-item')
.one('webkitAnimationEnd oanimationend msAnimationEnd animationend', function(e) {
$(this).remove();
});
}
});
});
/**
* Credit to Sara Soueidan
* @link https://github.com/SaraSoueidan/creative-list-effects/blob/master/css/styles-4.css
*/
.removed-item {
-webkit-animation: removed-item-animation .6s cubic-bezier(.55,-0.04,.91,.94) forwards;
-o-animation: removed-item-animation .6s cubic-bezier(.55,-0.04,.91,.94) forwards;
animation: removed-item-animation .6s cubic-bezier(.55,-0.04,.91,.94) forwards
}
@keyframes removed-item-animation {
from {
opacity: 1;
-webkit-transform: scale(1);
-ms-transform: scale(1);
-o-transform: scale(1);
transform: scale(1)
}
to {
-webkit-transform: scale(0);
-ms-transform: scale(0);
-o-transform: scale(0);
transform: scale(0);
opacity: 0
}
}
@-webkit-keyframes removed-item-animation {
from {
opacity: 1;
-webkit-transform: scale(1);
transform: scale(1)
}
to {
-webkit-transform: scale(0);
transform: scale(0);
opacity: 0
}
}
@-o-keyframes removed-item-animation {
from {
opacity: 1;
-o-transform: scale(1);
transform: scale(1)
}
to {
-o-transform: scale(0);
transform: scale(0);
opacity: 0
}
}
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width">
<title>JS Bin</title>
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css" rel="stylesheet"/>
</head>
<body>
<table class="table table-striped table-bordered table-hover">
<thead>
<tr>
<th>id</th>
<th>firstname</th>
<th>lastname</th>
<th>@twitter</th>
<th>action</th>
</tr>
</thead>
<tbody>
<tr class="item">
<td>1</td>
<td>Nour-Eddine</td>
<td>ECH-CHEBABY</td>
<th>@__chebaby</th>
<td><button class="btn btn-danger deleteItem">Delete</button></td>
</tr>
<tr class="item">
<td>2</td>
<td>John</td>
<td>Doe</td>
<th>@johndoe</th>
<td><button class="btn btn-danger deleteItem">Delete</button></td>
</tr>
<tr class="item">
<td>3</td>
<td>Jane</td>
<td>Doe</td>
<th>@janedoe</th>
<td><button class="btn btn-danger deleteItem">Delete</button></td>
</tr>
</tbody>
</table>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
</body>
</html>
- 1. Jquery: तत्व को बाहर निकालें
- 2. निकालें पिछले संलग्न तत्व jQuery
- 3. jQuery के साथ चर से डोम तत्व निकालें
- 4. java.util.List से तत्व को कैसे निकालें?
- 5. फ़ाइल से xml तत्व को कैसे निकालें?
- 6. jQuery के साथ एक डोम तत्व को कैसे नष्ट करें?
- 7. jquery के साथ बनाए गए तत्व को कैसे हटाएं?
- 8. निकालें स्ट्रिंग तत्व
- 9. Jquery के साथ एक संलग्न तत्व को कैसे निकालें और बाध्य या लाइव क्यों तत्वों को दोहराते हैं
- 10. PHP | सरलीकरण के साथ सरणी से तत्व निकालें?
- 11. jQuery के साथ कई एचटीएमएल 5 डेटा गुण निकालें
- 12. अपने माता-पिता को जानने के बिना डोम तत्व निकालें?
- 13. jQuery के साथ पुन: निष्पादित स्क्रिप्ट के बिना स्क्रिप्ट तत्व के साथ तत्व कैसे स्थानांतरित करें?
- 14. राफेल तत्व के लिए चमक कैसे जोड़ें और निकालें?
- 15. JQuery - एक तत्व
- 16. खाली तत्व के लिए पैडिंग निकालें
- 17. विशेषता के साथ jquery गिनती तत्व
- 18. JQTransform - स्टाइल से तत्व को बाहर निकालें?
- 19. एकाधिक गुणों के साथ jquery चुनिंदा तत्व
- 20. jQuery ड्रॉपपैबल, तत्व को
- 21. सरणी के तत्वों को कैसे निकालें?
- 22. निर्दिष्ट कक्षा के बिना तत्वों को कैसे निकालें
- 23. मैं jQuery के साथ एक डोम तत्व कैसे जोड़ूं?
- 24. जावास्क्रिप्ट में किसी सरणी से तत्व को कैसे निकालें?
- 25. एंड्रॉइड: ग्राफिक तत्व को फिर से कैसे निकालें?
- 26. Ehcache तत्व समाप्त होने पर कुंजी को कैसे निकालें?
- 27. jQuery के साथ केंद्रित तत्व कैसे प्राप्त करें?
- 28. jQuery के साथ एकाधिक HTML तत्व कैसे बनाएं?
- 29. उपयोग कैसे करें: jQuery के साथ jQuery
- 30. है कुछ तत्व के बाद सभी तत्वों को निकालें
.remove() विधि बहुत विशेष रूप से डोम से नोड को हटा देता है। .hide() विधि केवल प्रदर्शन विशेषता को बदलने के लिए परिवर्तित नहीं होती है, लेकिन अभी भी अस्तित्व में है। – micahwittman
$ (यह) .remove() बेहतर काम करता है। – Envil
@ एनील पोस्टर ने धीरे-धीरे इसे कैसे निकाला है। .remove() यह तुरंत करता है। – pixelearth