jQuery为什么要删除我的< img>元素? [英] Why is jQuery deleting my <img> element?

查看:133
本文介绍了jQuery为什么要删除我的< img>元素?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

单击链接后,我将jQuery与BlockUI插件一起使用来阻止页面.当页面被阻止时,我还使用DOM元素显示消息.

I'm using jQuery with the BlockUI plugin to block a page after a link is clicked. I'm also using a DOM element to display a message when the page is blocked.

这是使用的代码的简单示例:

Here's a simple example of the code used:

<a id="testme" href="#">Click Me</a>

<script type="text/javascript">
    $(document).ready(function() {
        $('#testme').click(function() {
            // Set our message in the message panel....
            $('#progressMessage').text('Please wait!');
            $.blockUI({
                message: $('#progressWidget')
            });
        });
    }
</script>

<div id="progressWidget" style="display:none" align="center">
    <div class="modalUpdateProgressMessage">
        <div id="progressMessage" />
        <img src="spinbar.gif" />
    </div>
</div>

我遇到的问题是,当我设置<div id="progressMessage" />元素的.text()时,<img src="spinbar.gif" />元素似乎被删除了.我已经证实使用Firebug确实在发生这种情况.

The problem I'm encountering is that when I set the .text() of the <div id="progressMessage" /> element, the <img src="spinbar.gif" /> element seems to get removed. I've verified that this is actually happening using Firebug.

我也尝试过使用<span>代替<div>来使用progressMessage,但是结果是相同的.

I've also tried using a <span> instead of a <div> for progressMessage but the result is the same.

谁能解释为什么会这样?

Can anyone explain why this is happening?

推荐答案

请勿执行自动关闭的DIV,这是无效的.

Don't do a self-closing DIV, it's not valid.

这篇关于jQuery为什么要删除我的&lt; img&gt;元素?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆