Insert image from the path in the html table using jquery/javascript

Viewed 21

I have a html table with id. It has two columns, the first one has text and the second column has a path to images that should be the background in the first row.

The second column must be hidden, but the cells in the first row must have the background based on the image path present in the second column.

Thanks in advance!

HTML CODE!

<html>
    <head>
        <title>Table</title>
        <style>
            #tab1, table, tr, td{
                border: 1px solid;
            }
        </style>
    </head>
    <body>
        <table id="tab1">
            <tr>
                <td>apple</td>
                <td>c:\Users\bta\Pictures\apple_logo.png</td>
            </tr>
            <tr>
                <td>orange</td>
                <td>c:\Users\bta\Pictures\orange_logo.png</td>
            </tr>
            <tr>
                <td>mango</td>
                <td>c:\Users\bta\Pictures\mango_logo.png</td>
            </tr>
            <tr>
                <td>peach</td>
                <td>c:\Users\bta\Pictures\peach_logo.png</td>
            </tr>
        </table>
    </body>
</html>
1 Answers

If you add anything between the tags (<>text</>), it will always works as plain text. If you want to add the background in html you have to do this inside the tag e.g. <td style='background:"c:\Users\bta\Pictures\orange_logo.png"'>some text here</td>

Related