Fadly Dzil
Fadly Dzil

Reputation: 2226

Get html with remove specific element on javascript/jquery

if my HTML is like this :

<tbody id="hasil-pencarian">
  <tr>
    <td align="center">1</td>
    <td>TMS/IT/06/001</td>
    <td>Erika Julia Widiyanti</td>
    <td>Marketing</td>
    <td>14-06-2015 13:59</td>
    <td>14-06-2015 14:00</td>
    <td>Erika test 1</td>

    <td id="action" class="center" width="10px">
        <a class="btn btn-success">
    </td>
   </tr>
</tbody>

I got all the html above like this :

var result = $("#hasil-pencarian").html();

But, How can I get all the HTML without the <td> with id='action' ? Little confused. Any help will be so appreciated.

Upvotes: 0

Views: 41

Answers (1)

Arun P Johny
Arun P Johny

Reputation: 388446

I think you could create clone then remove the element then get the content like

var result = $("#hasil-pencarian").clone().find('#action').remove().end().html();

Upvotes: 5

Related Questions