Thanhtu150
Thanhtu150

Reputation: 91

Find and remove <div> with correct "class" name I input

i have a sapmle html file:

  
 <!DOCTYPE html>
    <html>
      <body>
        <div id="userlist2">
            <div class="Guest2">
                Guest2

                <p class="Guest2">2 to 1 new test json</p>
            </div>

            <div class="Guest4">
                Guest4

                <p class="Guest4">4 to 1</p>
            </div>

            <div class="Guest5">
                Guest5

                <p class="Guest5">5 to 1 betatest</p>
            </div>
          </div>
      </body>
    </html>

Now i want to search and remove <div> in <div id="userlist2"> with correct class name I input, example: "Guest2". So, how can i do it with Javascript or jquery ?

Sorry about snippet, i cant post this code with Code Sample, it always getting error "It looks like your post is mostly code; please add some more details"

Upvotes: 0

Views: 60

Answers (1)

Varun
Varun

Reputation: 1946

You can use this,

$("#userlist2").find(".Guest2").remove();

Note This will remove the element from the DOM,not hide it

Upvotes: 4

Related Questions