Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to get a parentNode
    primarykey
    data
    text
    <p>Hey guy's just a quick question.</p> <p>Im making a sortable, drag and drop system and i need it, when the user drags the message to the delete box it will <strong>.remove();</strong> and will disappear (well remove it) but the issue is it removes the little elements of the message like the subject, I want it to remove the whole div for example one of the <strong>"message"</strong> elements. So how do you get the parentNode of this which is the <strong>message div</strong></p> <p>It does refresh the messages so don't worry about the messages </p> <p>The Code i have is </p> <pre><code>&lt;div class="message 1" id="1"&gt; // I want to remove this part and only this part &lt;ul id="8"&gt; &lt;li class="dragable" id="2"&gt; &lt;!-- Dragable --&gt; &lt;/li&gt; &lt;li class="checkbox" id="4"&gt; &lt;input type="checkbox" name="checkbox" class="checkbox" id="messagecheck1"&gt; &lt;/li&gt; &lt;li id="3"&gt; &lt;p&gt; hi&lt;/p&gt; &lt;/li&gt; &lt;/ul&gt; &lt;/div&gt; </code></pre> <p>js</p> <pre><code>$(".messageholder").sortable({ start: function(event, ui){ $(ui.item).css("opacity", "0.25"); draggable_sibling = $(ui.item).prev(); $(".deletebox").show(); }, stop: function(event, ui) { $(".deletebox").hide(); if (dropped) { if (draggable_sibling.length == 0) $('.messageholder').prepend(ui.item); draggable_sibling.after(ui.item); dropped = false; } $(ui.item).css("opacity", "1.00"); }, update: function(event, ui){ //Use's Xhr to save the position of the message var array = []; $(".messageholder div").each(function(e){ array.push($(this).attr('id')); }); $.ajax({ type: 'POST', url: 'json/save.php', data: ("data="+array) }); } }); $(".refresh").click(function(){ checkmessages(); }); $(".deletebox").droppable({ drop:function(event, ui){ dropped = true; $(event.target.parentNode).closest('div').remove(); } }); $(".messageholder").disableSelection(); </code></pre> <p>Their are multiple elements with the same class name so i can't remove the <strong>messages</strong> class out in one line of code, I would have to select the element individually and remove it like that. </p> <p><strong>Link</strong> <a href="http://grubber.co.nz/messages/" rel="nofollow">http://grubber.co.nz/messages/</a></p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload