How to hide th element in jquery

青灯夜游
Release: 2022-05-07 19:31:51
Original
3566 people have browsed it

Method: 1. Use "$("th").hide()" to hide by adding display style; 2. Use "$("th").fadeOut()" or "$( "th").fadeTo(milliseconds,0)", hide it by modifying the transparency; 3. Use "$("th").slideUp()".

How to hide th element in jquery

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

tag defines the header cell in the HTML table.

Example:

<table border="1">
	<tr>
		<th>商品</th>
		<th>价格</th>
	</tr>
	<tr>
		<td>T恤</td>
		<td>¥100</td>
	</tr>
	<tr>
		<td>牛仔褂</td>
		<td>¥250</td>
	</tr>
	<tr>
		<td>牛仔库</td>
		<td>¥150</td>
	</tr>
</table><br>
Copy after login

How to hide th element in jquery

Then use jquery to hide the th element

1. Use the hide()

hide() method to hide the selected element (hide it by adding the display:none style to the element).

$(document).ready(function() {
	$("button").click(function() {
		$("th").hide();
	});
});
Copy after login

How to hide th element in jquery

2. Use the fadeOut()

fadeOut() method to gradually change the opacity of the selected element, from visible to Hidden (fading effect).

$(document).ready(function() {
	$("button").click(function() {
		$("th").fadeOut();
	});
});
Copy after login

How to hide th element in jquery

3. Use the fadeTo()

fadeTo() method to gradually change the opacity of the selected element to the specified value. (faded effect).

Just set the final opacity to 0.

$(document).ready(function() {
	$("button").click(function() {
		$("th").fadeTo(1000,0);
	});
});
Copy after login

How to hide th element in jquery

4. Use the slideUp()

slideUp() method to hide the selected element in a sliding manner.

$(document).ready(function() {
	$("button").click(function() {
		$("th").slideUp();
	});
});
Copy after login

How to hide th element in jquery

[Recommended learning: jQuery video tutorial, web front-end video

The above is the detailed content of How to hide th element in jquery. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template