Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to get text after <br>?

Tags:

html

jquery

I have the following html format,

<tr>
    <td width="80%" style="padding-bottom: 3px" class="ms-vb">
        <span class="ms-announcementtitle">
            title is here 3
        </span>
        <br>
        by Ahmed 1
    </td>
</tr>
<tr>
    <td width="80%" style="padding-bottom: 3px" class="ms-vb">
        <span class="ms-announcementtitle">
            title is here 2
        </span>
        <br>
        by Ahmed 2
    </td>
</tr>
<tr>
    <td width="80%" style="padding-bottom: 3px" class="ms-vb">
        <span class="ms-announcementtitle">
            title is here 3
        </span>
        <br>
        by Ahmed 3
    </td>
</tr>

how to use jQuery to get the text after <br> i.e. by Ahmed 1, by Ahmed 2, by Ahmed 3

like image 642
Ahmed Atia Avatar asked Dec 21 '22 06:12

Ahmed Atia


1 Answers

var text = [];
$('.ms-vb').each(function() {
  text.push($(this).html().split('<br>')[1]);
});
like image 72
Phil Avatar answered Jan 07 '23 19:01

Phil