1

I cant seem to find the right jquery selector for this tag:

HTML:

<div class="span4 span4-mod">
    <div class="well well-mod">
    <h4 class="DomainDescription">Iniz LAX1</h4>
    <span class="btn-block">
        <button></button>
    </span>
    <form action="pinfo.php" method="post">
        <input type="hidden" value="">
        <button>History</button>    
    </form>
    Port Status<br />
    <span class="portstatus porton">21</span>
    <table class="table" style="margin-top: 10px;">
        <tbody>
            <tr>
                <td><strong>Distro:</strong></td>
                <td class="showdistro">Debian 7.1</td>
            </tr>
            <tr>
                <td><strong>Online since: </strong></td>
                <td class="showonline">2 Days 10:29</td>
            </tr>
        </tbody>
    </table>    
</div>

I'm trying to search for the class "DomainDescription", and then search for the HTML within the class "showonline", and manipulate the latter.

I'm looking for the relationship of sibling (table) >child (tbody) > child (tr) > child (td)

Try as I may, I cant seem to find a proper selector for this kind of relationship.

I began by:

$('.DomainDescription').each(function () {                  
    var PrintedUptime=$(this).siblings().children(".showonline").html();
    alert (PrintedUptime);
});

What should the proper selector be?

4

2 に答える 2

1

あなたはできる

$('.DomainDescription').each(function () {                  
    var PrintedUptime=$(this).closest('.well-mod').find(".showonline").html();
    alert (PrintedUptime);
});

デモ:フィドル

于 2013-08-23T06:19:56.510 に答える