title: How to auto destroy a DOM element after a specific time using Jquery
body: <p>Is it possible to remove a HTML element after specified time?</p>
  
  <p>Also if a condition satisfied in between the specified time, I need to stop the timer from removing the element.</p>
  
  <p>Sample code,</p>
  
  <pre><code>&lt;ul&gt;
     &lt;li  data-id="25"&gt;
        &lt;a class="online"&gt;Marco&lt;/a&gt;
     &lt;/li&gt;
     &lt;li  data-id="53"&gt;
        &lt;a class="online busy"&gt;Polo&lt;/a&gt;
     &lt;/li&gt;
  &lt;/ul&gt;
  </code></pre>
  
  <p>When the user Marco's goes offline, I need to remove the Marco's <code>&lt;li&gt;</code> after 10 secs but if he comes back online within 10 secs the timer should be stoped and <code>&lt;li&gt;</code> should not be removed.</p>
  
  <p>Socket handles the user online status:</p>
  
  <pre><code>socket.on('user_connected', function(data){
     var uId = data['uId'];
     ///
  });
  
  socket.on('user_disconnected', function(data){
     var uId = data['uId'];
     ///
  });
  </code></pre>
  
  <p>Can anybody please give me a generic solution to remove an element using the timer and stop the timer before removing the element?</p>