jquery删除tr失败的解决办法:1、通过“$(temp)”先获取到该td对象;2、通过“.parent()”获取到td的tr;3、使用“remove()”方法删除tr即可。
本文操作环境:windows7系统、jquery1.2.6版、DELL G3电脑
jquery 删除tr失败怎么办?
jQuery移除tr无效的解决方法(tr是动态添加)
今天在做项目时,碰到一个问题,那就是移除掉某些tr(tr是动态添加的)。尝试了很多方法,都不见效(比如,deleteRow方法,貌似传的参数只能是tr的行数。没有仔细研究目前)。后来,发现这个方法效果不错,特此记录。
$(temp).parent().remove(); //temp为td的id <code class="js plain"> 我的理解是这样的:$(temp)先获取到该td对象,然后.parent()获取到td的tr,再remove()方法,删除tr。</code>
html代码:
<table> <tr> <td><a href='#' onclick='removeTr(this)'>123</a></td> <td><a href='#' onclick='removeTr(this)'>456</a></td> </tr> <tr> <td><a href='#' onclick='removeTr(this)'>aaa</a></td> <td><a href='#' onclick='removeTr(this)'>bbb</a></td> </tr> ;/table>
js代码:
function removeTr(temp){ mp).parent().parent().remove(); //必须保证页面已经引入了jQuery才可以使用 //此处$(temp)先获取到<a>对象,.parent()拿到<td>,再.parent()获取到tr }
推荐学习:《jquery视频教程》
以上是jquery 删除tr失败怎么办的详细内容。更多信息请关注PHP中文网其他相关文章!

No,youshouldn'tusemultipleIDsinthesameDOM.1)IDsmustbeuniqueperHTMLspecification,andusingduplicatescancauseinconsistentbrowserbehavior.2)Useclassesforstylingmultipleelements,attributeselectorsfortargetingbyattributes,anddescendantselectorsforstructure

html5aimstoenhancewebcapabilities,Makeitmoredynamic,互动,可及可访问。1)ITSupportsMultimediaElementsLikeAnd,消除innewingtheneedtheneedtheneedforplugins.2)SemanticeLelelemeneLementelementsimproveaCceccessibility inmproveAccessibility andcoderabilitile andcoderability.3)emply.3)lighteppoperable popperappoperable -poseive weepivewebappll

html5aimstoenhancewebdevelopmentanduserexperiencethroughsemantstructure,多媒体综合和performanceimprovements.1)SemanticeLementLike like,和ImproVereAdiability and ImproVereAdabilityAncccossibility.2)和TagsallowsemplowsemplowseamemelesseamlessallowsemlessemlessemelessmultimedimeDiaiiaemediaiaembedwitWithItWitTplulurugIns.3)

html5isnotinerysecure,butitsfeaturescanleadtosecurityrisksifmissusedorimproperlyimplempled.1)usethesand andboxattributeIniframestoconoconoconoContoContoContoContoContoconToconToconToconToconToconTedContDedContentContentPrevulnerabilityLikeClickLickLickLickLickLickjAckJackJacking.2)

HTML5aimedtoenhancewebdevelopmentbyintroducingsemanticelements,nativemultimediasupport,improvedformelements,andofflinecapabilities,contrastingwiththelimitationsofHTML4andXHTML.1)Itintroducedsemantictagslike,,,improvingstructureandSEO.2)Nativeaudioand

使用ID选择器在CSS中并非固有地不好,但应谨慎使用。1)ID选择器适用于唯一元素或JavaScript钩子。2)对于一般样式,应使用类选择器,因为它们更灵活和可维护。通过平衡ID和类的使用,可以实现更robust和efficient的CSS架构。

html5'sgoalsin2024focusonrefinement和optimization,notnewfeatures.1)增强performandemandeffifice throughOptimizedRendering.2)risteccessibilitywithrefinedibilitywithRefineDatientAttributesAndEllements.3)expliencernsandelements.3)explastsecurityConcerns,尤其是withercervion.4)

html5aimedtotoimprovewebdevelopmentInfourKeyAreas:1)多中心供应,2)语义结构,3)formcapabilities.1)offlineandstorageoptions.1)html5intoryements html5introctosements introdements and toctosements and toctosements,简化了inifyingmediaembedingmediabbeddingingandenhangingusexperience.2)newsements.2)


热AI工具

Undresser.AI Undress
人工智能驱动的应用程序,用于创建逼真的裸体照片

AI Clothes Remover
用于从照片中去除衣服的在线人工智能工具。

Undress AI Tool
免费脱衣服图片

Clothoff.io
AI脱衣机

Video Face Swap
使用我们完全免费的人工智能换脸工具轻松在任何视频中换脸!

热门文章

热工具

WebStorm Mac版
好用的JavaScript开发工具

SublimeText3 Linux新版
SublimeText3 Linux最新版

SublimeText3 Mac版
神级代码编辑软件(SublimeText3)

Atom编辑器mac版下载
最流行的的开源编辑器

Dreamweaver CS6
视觉化网页开发工具