简体   繁体   中英

Jquery Remove from onclick inside div

I have this simple code

<div id="adic">hello world</div>
<span onclick='jQuery.remove("#adic")'>DEL</span><br>

I want only remove div with id adic,but if use onclick don´t works, i don´t know if howewer i put some bad or howewer i do something wrong, because if use ths function in script and call script, works but from inside onclick inside span for remove other div, no works

Thank´s in advanced

Try this : $("#adic").remove() .

 <script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script> <div id="adic">hello world</div> <span onclick='$("#adic").remove()'>DEL</span><br> 

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM