manishjangir
manishjangir

Reputation: 1695

Remove a particular div of specific text

I have the following code in a php page

<div class="vmenu">

  <div class="first_li"><span >Add Shift</span></div>
 <div class="first_li"><span>Add Comment</span></div>

 </div>

Now I want to remove the div contains text "Add Shift" on document ready

Upvotes: 0

Views: 128

Answers (3)

mas-designs
mas-designs

Reputation: 7536

$('div.vmenu div:first-child').remove();

check it out on jsfiddle: http://jsfiddle.net/7CFAq/

Upvotes: 0

ZloiGremlin
ZloiGremlin

Reputation: 26

$(function(){

    $('.first_li span:contains('Add Shift')').remove();
});

Upvotes: 1

Joseph
Joseph

Reputation: 119837

Use jQuery .remove() and :contains(). Note that it's case sensitive

$('div:contains("Add Shift")').remove();

Upvotes: 1

Related Questions