Find an html element which has a class but the class name is varying or unknown

117 Views Asked by At

Find an html element which has a class but the class name is varying or unknown.

<table>
        <tr>
            <td></td>
            <td></td>
        </tr>
        <tr>
            <td></td>
            <td></td>
        </tr>
        <tr>
            <td></td>
            <td>
                <table>
                    <tr>
                        <td></td>
                        <td></td>
                    </tr>
                    <tr>
                        <td></td>
                        <td></td>
                    </tr>
                    <tr>
                        <td></td>
                        <td>
                            <table class="jasdhuioheurbyiwefnio">
                                <tr>
                                    <td></td>
                                    <td></td>
                                </tr>
                                <tr>
                                    <td></td>
                                    <td></td>
                                </tr>
                                <tr>
                                    <td></td>
                                    <td></td>
                                </tr>
                            </table>
                        </td>
                    </tr>
                </table>
            </td>
        </tr>
    </table>

In the above html only one table has a class(class="jasdhuioheurbyiwefnio") The class name is a dynamically changing. How to Get the table?

3

There are 3 best solutions below

0
On BEST ANSWER

You can try

table[class] 

selector "table that has class attribute". But it's not very reliable though, since it can match more tables than you need.

0
On

Have you tried $("table[class]")?

1
On

write one static Id and get the table through the ID.