Home  >  Article  >  Web Front-end  >  jquery delete specified child element code example

jquery delete specified child element code example

韦小宝
韦小宝Original
2017-11-28 10:05:271184browse

jQueryDelete a specified sub-element code example. This chapter introduces how to use jQuery to delete a specified sub-element. Let us learn how Use jQuery to delete specified child elements!

How to use native javascript to implement this function, please refer to the chapter of native javascript deleting specified sub-element code examples.
In fact, there are many ways to implement this function. The following is an introduction to one of the more common ones.
The code examples are as follows:

<!DOCTYPE HTML>
<html>
<meta charset="utf-8">
<title>PHP中文网</title>
<style>
ul li{
  width:400px;
  height:30px;
  line-height:30px;
  list-style:none;
}
</style>
<script src="http://libs.baidu.com/jquery/1.9.0/jquery.js"></script>
<script>
$(document).ready(function(){
  $("#bt").click(function(){
    $($("#box").find("li")[1].remove());
  })
})
</script>
</head>
<body>
<ul id="box">
  <li>程序员之家欢迎您,只有努力奋斗才会有美好的明天。</li>
  <li>没有任何人一开始就是高手,必须要努力奋斗才行。</li>
  <li>每一天都是新的,要好好的珍惜时间。</li>
</ul>
<input type="button" id="bt" value="查看效果"/>
</body>
</html>

The above code realizes our requirements. It is relatively simple and will not be introduced here. More For more information, please refer to related readings.

Related reading:

jQuery method of operating the Nth element

jquery implements gesture unlocking source code

How to use jquery efficiently

The above is the detailed content of jquery delete specified child element code example. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn