locked
how to read src in the table and put into the array RRS feed

  • Question

  • User-1634604574 posted

    i have this table i want to read src in each row and put it into the array i wrote this code but is not working fine

    <table id="example">
    <tr>
    <td><img src="@Url.Content("~/img/Checkmark.png")" style="width:18px;height:18px"></td>
    </tr>
    
    <tr>
    <td><img src="@Url.Content("~/img/Checkmark.png")" style="width:18px;height:18px"></td>
    </tr>
    
    <tr>
    <td><img src="@Url.Content("~/img/close.png")" style="width:18px;height:18px"></td>
    </tr>
    
    <tr>
    <td><img src="@Url.Content("~/img/close.png")" style="width:18px;height:18px"></td>
    </tr>
    
    <tr>
    <td><img src="@Url.Content("~/img/Checkmark.png")" style="width:18px;height:18px"></td>
    </tr>
    </table>
    
    
    <script>
    var arr_image2=[]
     $('#example tr').filter(function () {
                    arr_image2.push($(this).find('td:nth-of-type(7)img').attr('src'))
                })
    
     for (var i = 0; i < arr_image2.length; i++) {
    
                    alert(arr_image2[i])
    }
    </script>
    

    Friday, May 3, 2019 9:26 AM

All replies