Home  >  Article  >  Web Front-end  >  How to hide the first a tag in jquery

How to hide the first a tag in jquery

青灯夜游
青灯夜游Original
2022-05-25 18:00:051760browse

Hide method: 1. Use the ":first" selector to obtain the first a tag element, the syntax is "$("a:first")"; 2. Use hide() or fadeOut() to hide the acquisition To the a element object, the syntax is "a element object.hide(millisecond value)" or "a element object.fadeOut(millisecond value)".

How to hide the first a tag in jquery

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

How to hide the first a tag in jquery

##1. Use the :first selector to select The first a tag element

:first selector selects the first element.

$("a:first")

Note: This selector is only used to select a single element.

2. Use the hide() or fadeOut() method to hide the selected element



	
		
		
		<script>
			$(document).ready(function() {
				$("button").on("click", function() {
					$(&quot;a:first&quot;).hide(1000); 
					//$(&quot;a:first&quot;).fadeOut(1000);
				});
			});
		</script>
	

	
		第一个a标签
第二个a标签
第三个a标签

How to hide the first a tag in jquery

[Recommended learning:

jQuery video tutorialwebfront-end video

The above is the detailed content of How to hide the first a tag in jquery. 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