Find an Inner Div Which Has A Particular Attribute And Remove

In this code, we will find an inner div which has a particular attribute and delete the same.

Using The Code

Consider following is my HTML

  1. <div class="dragDiv">  
  2.    <div id="dragDivInner">  
  3.       <div myid="1" class="droppable" myval="I"></div>  
  4.       <div myid="2" class="droppable"></div>  
  5.    </div>  
  6. </div>  

And what if, I need to find out a div which has attribute value ‘myid’=2 dynamically?

  1. $(".dragDiv div[myid=" + ui.item.attr('myid') + "]").remove();  

Here ui.item.attr(‘myid’) is the attribute value I am getting dynamically.

Please see other code snippets here: Code-Snippets.