动态创建 div 时如何显示/隐藏 div [英] how to show/hide divs when divs are created dynamically

查看:23
本文介绍了动态创建 div 时如何显示/隐藏 div的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在开发具有两个级别的评论重播评论系统,我在如何显示和隐藏 div 方面遇到了问题 ..,因为它的 id 是不同的 ..,我尝试了一种方式:

I am developing comment systems with two level of replay to the comments and I have a problem with how to show and hide divs .., because it's id's are different .., I tried in a way with:

<button>replayl</button>

<span style="display:none;">
   <form action='' method='post' name="addcmt" onsubmit="return validate()">
        <textarea rows="1" cols="60" name='textarea1' id='textarea1' onKeyDown="limitText(this.form.textarea1,this.form.countdown,300);" 
                                  onKeyUp="limitText(this.form.textarea1,this.form.countdown,300);">
       </textarea>
       <br>
       <br>
       <input type="hidden" name="level1" id="level1" value="commtlevel1" />
       <input id='addcmt' type='submit' value='Add reply' name='submit'/> 
   </form>
</span>

和jquery:

 <script>
     $("button").click(function () {
        $("span").show();                 
     });
</script>

但是这样当我点击回复按钮时,它会显示所有的 span 标签内容......,我想知道我如何只显示一个标签或一种完成工作的方式.

but this way when I click reply button it shows all the span tag contente.., I wanna kow how I show one tag only or a way to my work done.

推荐答案

编辑后的问题,我建议你使用 div 而不是 span (因为 display inline vs block).

After edited question, i suggest you use div instead of span (because of display inline vs block).

$("button").click(function () {
    $(".myform").toggle('slow');
});

可以按照您的意愿完成工作.这是结果.

would do the job how you want.Here is the result.

这篇关于动态创建 div 时如何显示/隐藏 div的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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