javascript - remove all <div> , when ids are in matching some pattern -
all divs inside of div #main
have tree structure of lots of divs.but divs not child of other div, connected 1 line, divs generating @ run time , generating id of div, following pattern id of first child node= id of parent node+"1" , id of second child node= id of parent node+"2"
id of root div node id of first child node node1 id of second child node node2 id of first child of node1 node11 id of second child of node1 node12 id of first child of node11 node111 id of second child of node11 node112 ... ... ...
requirement: if click on div, child nodes till leaf should deleted.
you can use starts attribute selector [name^="value"] child elements have ids starts id
of parent.
$('#main div').click(function(){ $('[id^='+this.id + ']').remove(); });
Comments
Post a Comment