JQuery添加div移除div_html/css_WEB-ITnose
jquery
<div class="block_comments"> <div class="comment"> <div class="userpic"><a href="#"><img src="/static/imghw/default1.png" data-src="images/ava_default_1.jpg" class="lazy" alt="" /></a></div> <div class="content"> <p class="name"><a href="#">路人甲</a></p> <p class="text">我认为人们要感恩的人哟很多法撒旦法涉及多方考虑斯达康减肥就算了打开解放累进税率大幅速卡戴假发就算了打开房间速率可达飞机螺丝钉棵发了看似简单</p> <p class="info"><a href="#none" class="control" id="rep" >回复</a> </p> </div> <!--点击回复后这里加上一个div--> <div class="clearboth"></div> <div class="line_3"></div> </div> <div class="comment"> <div class="userpic"><a href="#"><img src="/static/imghw/default1.png" data-src="images/ava_default_1.jpg" class="lazy" alt="" /></a></div> <div class="content"> <p class="name"><a href="#">路人甲</a></p> <p class="text">我认为人们要感恩的人哟很多法撒旦法涉及多方考虑斯达康减肥就算了打开解放累进税率大幅速卡戴假发就算了打开房间速率可达飞机螺丝钉棵发了看似简单</p> <p class="info"><a href="#none" class="control" id="rep" >回复</a> </p> </div> <!--点击回复后这里加上一个div--> <div class="clearboth"></div> <div class="line_3"></div> </div> <div class="comment"> <div class="userpic"><a href="#"><img src="/static/imghw/default1.png" data-src="images/ava_default_1.jpg" class="lazy" alt="" /></a></div> <div class="content"> <p class="name"><a href="#">路人甲</a></p> <p class="text">我认为人们要感恩的人哟很多法撒旦法涉及多方考虑斯达康减肥就算了打开解放累进税率大幅速卡戴假发就算了打开房间速率可达飞机螺丝钉棵发了看似简单</p> <p class="info"><a href="#none" class="control" id="rep" >回复</a> </p> </div> <!--点击回复后这里加上一个div--> <div class="clearboth"></div> <div class="line_3"></div> </div> </div>
1,点击回复后在那里加一个div,在点击这个回复时这个div移除,
2,点其中一个回复后再点击其两个回复时,只能有一个div,其他的移除,
3,也就是说不管点哪个,只能有一个新div出现
回复讨论(解决方案)
<!DOCTYPE html PUBLIC "-//W3C//Dtd XHTML 1.0 transitional//EN" "http://www.w3.org/tr/xhtml1/Dtd/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><meta http-equiv="Content-Type" content="text/html; charset=GB2312" /><script type = "text/javascript" src = "js/jquery.js"></script><title>无标题文档</title><style type = "text/css"></style></head><script>$(function(){ $(".control").click(function(){ $("div.insertDiv").remove(); $(this).parents().next(".clearboth").before("<div class= 'insertDiv'>charuchenggong</div>"); return false; });});</script><body><div> <div> <div class="content"> <p class="name"><a href="#">路人甲</a></p> <p class="text">我</p> <p class="info"><a href="#none" class="control" id="rep" >回复</a> </p> </div> <div class="clearboth">sdf</div> <div class="line_3">sd</div> </div> <div class="comment"> <div class="content"> <p class="name"><a href="#">路人甲</a></p> <p class="text">我认为</p> <p class="info"><a href="#none" class="control" id="rep1" >回复</a> </p> </div> <!--点击回复后这里加上一个div--> <div class="clearboth">435</div> <div class="line_3">345</div> </div></div></body></html>
把那段加上,就可以了,同时,在同一个页面,不要用相同的id,如果你需要那一组用同样的操作,可以用class,id相同等于把id这个属性废了。

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics



HTML is suitable for beginners because it is simple and easy to learn and can quickly see results. 1) The learning curve of HTML is smooth and easy to get started. 2) Just master the basic tags to start creating web pages. 3) High flexibility and can be used in combination with CSS and JavaScript. 4) Rich learning resources and modern tools support the learning process.

The article discusses the HTML <progress> element, its purpose, styling, and differences from the <meter> element. The main focus is on using <progress> for task completion and <meter> for stati

HTML defines the web structure, CSS is responsible for style and layout, and JavaScript gives dynamic interaction. The three perform their duties in web development and jointly build a colorful website.

The article discusses the HTML <datalist> element, which enhances forms by providing autocomplete suggestions, improving user experience and reducing errors.Character count: 159

The article discusses the HTML <meter> element, used for displaying scalar or fractional values within a range, and its common applications in web development. It differentiates <meter> from <progress> and ex

AnexampleofastartingtaginHTMLis,whichbeginsaparagraph.StartingtagsareessentialinHTMLastheyinitiateelements,definetheirtypes,andarecrucialforstructuringwebpagesandconstructingtheDOM.

WebdevelopmentreliesonHTML,CSS,andJavaScript:1)HTMLstructurescontent,2)CSSstylesit,and3)JavaScriptaddsinteractivity,formingthebasisofmodernwebexperiences.

GiteePages static website deployment failed: 404 error troubleshooting and resolution when using Gitee...
