Home  >  Article  >  Web Front-end  >  How jquery controls css to delete elements

How jquery controls css to delete elements

青灯夜游
青灯夜游Original
2022-01-20 17:22:522622browse

In jquery, you can use the css() method to control css, add the "display: none;" style to the element, and then delete the element; the syntax format is "$("element").css(" display", "none");".

How jquery controls css to delete elements

The operating environment of this tutorial: windows7 system, jquery1.10.2 version, Dell G3 computer.

In jquery, you can use the css() method to control css, add the "display: none;" style to the element, and then delete the element

css() Method returns or sets one or more style properties of the matched element.

Implementation code:

<!DOCTYPE html>
<html>
	<head>
		<script src="js/jquery-1.10.2.min.js"></script>
		<script>
			$(document).ready(function() {
				$("#btn").click(function() {
					$("#box").css("display", "none");
				});
			});
		</script>
	</head>

	<body>
		<div>测试元素</div>
		<div id="box">测试box元素</div>
		<div>测试元素</div><br>
		<button id="btn">点击删除box元素</button>
	</body>

</html>

How jquery controls css to delete elements

Related video tutorial recommendations: jQuery tutorial (video)

The above is the detailed content of How jquery controls css to delete elements. 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