简体   繁体   English

使用 jquery/javascript 从 html 表中的路径插入图像

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

I have a html table with id.我有一个带有 id 的 html 表。 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 代码!

<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>

If you add anything between the tags ( <>text</> ), it will always works as plain text.如果您在标签 ( <>text</> ) 之间添加任何内容,它将始终作为纯文本工作。 If you want to add the background in html you have to do this inside the tag eg <td style='background:"c:\Users\bta\Pictures\orange_logo.png"'>some text here</td>如果您想在 html 中添加背景,您必须在标签内执行此操作,例如<td style='background:"c:\Users\bta\Pictures\orange_logo.png"'>some text here</td>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM