简体   繁体   English

在表中使用innerhtml调用

[英]Using innerhtml call within a table

I am trying to use innerHTML to place a dynamic image within a row of a table I have on my page. 我正在尝试使用innerHTML在页面上的表格行中放置动态图像。 The image is showing up, however, it is floating to the top of the table for some reason. 该图像正在显示,但是由于某种原因它浮在表格的顶部。 Is there any way to ensure it stays in the row that I have it in. Here are some snippits of the code: 有什么方法可以确保它停留在我所在的行中。这是一些代码片段:

In the javascript: 在javascript中:

document.getElementById("myResults").innerHTML = ""; document.getElementById(“ myResults”)。innerHTML =“”;

In the html: 在html中:

<td class="label"><label for="description">Description:</td>

                                        </tr>
                                        <tr>
                                        <td class="label">
                                            <div class ="<?php echo form_row_class("bio") ?>" >
                                            <div class="styled_textarea">
                                                <textarea type="text" id="bio" onfocus="this.value=''; setbg('#f0f7f8');" onblur="setbg('white')" name="bio" value="<?php echo h($_POST['bio']); ?>" rows="10"></textarea>
                                            </div>
                                            </div>
                                        </td>

                                        </tr>


                                        <tr>
                                        <td class="label"><label for="image"><div class="vspace2em"></div>Image:</label></td>
                                        </tr>
                                        <tr>
                                        <td class="label">

<a id="edit_image"></a>
<div class="row">
<div class="span10 offset1">
<div id="editpane">
<button class="btn btn-large btn-primary openbutton" type="button">Open an Image</button>
</div>
</div>
</div>


                                        </td>



                                        <td>

                                            <?php if($current_user2): ?>

                                                <?php if($current_user2['filepicker'] != ''): ?>

                                                    <img src="<?php echo $current_user2['filepicker'];?>">

                                                <?php endif; ?>

                                            <?php endif; ?>

                                        </td>
                                        </tr>

                                        <tr>

                                         <div id="myResults"></div>

                                        </tr>

etc... 等等...

The image called with the innerHTML using floats to the top of the table for some reason, without appearing where I have it situated. 由于某种原因,使用innerHTML使用浮动图像调用到表的顶部,而没有出现在我的位置。 Any ideas why this is happening? 任何想法为什么会这样?

It would be more clearer to read if you formatted the HTML table right. 如果您正确格式化了HTML表,那么阅读起来会更加清晰。 From the first glance I see that you have 乍一看,我知道你有

<tr>
    <div id="myResults"></div>
</tr>

myResults is your relevant div. myResults是您相关的div。 The problem is you dont have any <td> elements inside the <tr> . 问题是您在<tr>没有任何<td>元素。 I think your code should look like this. 我认为您的代码应如下所示。

<tr>
    <td>
        <div id="myResults"></div>
    </td>
</tr>

This should give you the desired result. 这应该给您期望的结果。

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

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