locked
how to pass image from one table to another table RRS feed

  • Question

  • User-1634604574 posted

    i have this table i want by loop pass column image from first table into the second column of second table

    <table id="tb1">
    <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>
    
    <table id="tb2">
    <tr>
    <td>1</td>
    <td><td>
    </tr>
    
    <tr>
    <td>2</td>
    <td><td>
    </tr>
    
    <tr>
    <td>3</td>
    <td><td>
    </tr>
    
    <tr>
    <td>4</td>
    <td><td>
    </tr>
    
    <tr>
    <td>5</td>
    <td><td>
    </tr>
    </table>
    

    Wednesday, May 1, 2019 8:19 PM

All replies

  • User475983607 posted

    In the future please post the code you tried and explain the expected results and actual results.

    @{
        Layout = null;
    }
    
    <!DOCTYPE html>
    
    <html>
    <head>
        <meta name="viewport" content="width=device-width" />
        <title>Index</title>
    </head>
    <body>
        <div>
            <table id="tb1">
                <tr>
                    <td><img src="@Url.Content("~/images/Checkmark.png")" style="width:18px;height:18px"></td>
                </tr>
    
                <tr>
                    <td><img src="@Url.Content("~/images/Checkmark.png")" style="width:18px;height:18px"></td>
                </tr>
    
                <tr>
                    <td><img src="@Url.Content("~/images/close.png")" style="width:18px;height:18px"></td>
                </tr>
    
                <tr>
                    <td><img src="@Url.Content("~/images/close.png")" style="width:18px;height:18px"></td>
                </tr>
    
                <tr>
                    <td><img src="@Url.Content("~/images/Checkmark.png")" style="width:18px;height:18px"></td>
                </tr>
            </table>
    
            <table id="tb2">
                <tr>
                    <td>1</td>
                    <td>
                    </td>
                </tr>
    
                <tr>
                    <td>2</td>
                    <td>
                    </td>
                </tr>
    
                <tr>
                    <td>3</td>
                    <td>
                    </td>
                </tr>
    
                <tr>
                    <td>4</td>
                    <td>
                    </td>
                </tr>
    
                <tr>
                    <td>5</td>
                    <td>
                    </td>
                </tr>
            </table>
        </div>
        <script src="https://code.jquery.com/jquery-1.12.4.js"></script>
        <script>
            var images = [];
            $('img').each(function (index, value) {
                images.push($(this).clone());
            });
            $('#tb2 tbody tr').each(function (index, value) {
                var td = $(this).find('td:nth-child(2)');
                td.append(images[index])
            });
        </script>
    </body>
    </html>
    

    Wednesday, May 1, 2019 9:17 PM
  • User-1634604574 posted

    what if i want to pass two column of image from one table to another?

    <table id="tb1">
    <tr>
    <td><img src="@Url.Content("~/img/Checkmark.png")" style="width:18px;height:18px"></td>
    <td><img src="@Url.Content("~/img/Checkmark2.png")" style="width:18px;height:18px"></td>
    </tr>
    
    <tr>
    <td><img src="@Url.Content("~/img/Checkmark.png")" style="width:18px;height:18px"></td>
    <td><img src="@Url.Content("~/img/Checkmark2.png")" style="width:18px;height:18px"></td>
    </tr>
    
    <tr>
    <td><img src="@Url.Content("~/img/close.png")" style="width:18px;height:18px"></td>
    <td><img src="@Url.Content("~/img/Checkmark2.png")" style="width:18px;height:18px"></td>
    </tr>
    
    <tr>
    <td><img src="@Url.Content("~/img/close.png")" style="width:18px;height:18px"></td>
    <td><img src="@Url.Content("~/img/Checkmark2.png")" style="width:18px;height:18px"></td>
    </tr>
    
    <tr>
    <td><img src="@Url.Content("~/img/Checkmark.png")" style="width:18px;height:18px"></td>
    <td><img src="@Url.Content("~/img/Checkmark2.png")" style="width:18px;height:18px"></td>
    </tr>
    </table>
    
    <table id="tb2">
    <tr>
    <td>1</td>
    <td><td>
    <td><td>
    </tr>
    
    <tr>
    <td>2</td>
    <td><td>
    <td><td>
    </tr>
    
    <tr>
    <td>3</td>
    <td><td>
    <td><td>
    </tr>
    
    <tr>
    <td>4</td>
    <td><td>
    <td><td>
    </tr>
    
    <tr>
    <td>5</td>
    <td><td>
    <td><td>
    </tr>
    </table>

    Wednesday, May 1, 2019 9:36 PM
  • User475983607 posted

    what if i want to pass two column of image from one table to another?

    I answered your first question.  This is a new question. 

    I recommend you at least try to solve this very simple programming problem.  Post you code if you run into trouble.

    Wednesday, May 1, 2019 11:31 PM