87,989
社区成员
发帖
与我相关
我的任务
分享
<input id=1……> <img onclick="aa(this)">
<input id=2……> <img onclick="aa(this)">
.
.
.
<input id=n……> <img onclick="aa(this)">
function aa(x){
$(x).prev("input").remove();
$(x).remove();
}
<html lang="zh"><!-- TODO(dbeam): dir="ltr"? --><!-- Copyright 2015 The Chromium Authors. All rights reserved.
Use of this source code is governed by a BSD-style license that can be
found in the LICENSE file. --><head></head>
<body class="light-chip win inited" style="background: rgb(255, 255, 255); --logo-color:rgba(238,238,238,1);">
<input id="1……"> <img onclick="aa(this)" src="https://profile.csdnimg.cn/9/8/A/1_u011548042">
<script>
aa = (el)=>{
el.previousSibling.remove()
}
</script>
</body></html>
<html lang="zh"><!-- TODO(dbeam): dir="ltr"? --><!-- Copyright 2015 The Chromium Authors. All rights reserved.
Use of this source code is governed by a BSD-style license that can be
found in the LICENSE file. --><head></head>
<body class="light-chip win inited" style="background: rgb(255, 255, 255); --logo-color:rgba(238,238,238,1);">
<input id="1……"> <img onclick="aa(this)" src="https://profile.csdnimg.cn/9/8/A/1_u011548042">
<script>
aa = (el)=>{
el.previousSibling.remove()
}
</script>
</body></html>
<div><input id=1……> <img onclick="aa(this)"></div>
function aa(x){
$(x).parent().remove();
}
[/quote]
感谢回复 。但是请看清我的主贴,前提是 input和img 不在一个标签中 是2个独立的标签 如过在一个标签中就不是事了啊
<div><input id=1……> <img onclick="aa(this)"></div>
function aa(x){
$(x).parent().remove();
}