if table is dispalyed border should display if it is hidden border should be remove.

how to write if else condition  if table is displayed  border "class" should add . and if table is not displayed border  ''"class" should remove.
 This is Sample Code only. 
when i am hidding the table border is displayed i want to hide the border when table is hidden. 
<!DOCTYPE html>
<html>
<head>
	<title></title>
	<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
	<style type="text/css">
		.border{
			border:1px solid red;
		}
	</style>

	<script type="text/javascript">
		$(document).ready(function(){
			if ($(table) == display:none) {
				$(table).removeClass("border")
			}
		})
	</script>



</head>
<body>

	<div class="border">
		<table>
			<thead>
				<th>2121321</th>
				<th>2121321</th>
				<th>2121321</th>
				<th>2121321</th>
				<th>2121321</th>
				<th>2121321</th>
				<th>2121321</th>

			</thead>
			<tbody>
				<tr>
				<td>2121321</td>
				<td>2121321</td>
				<td>2121321</td>
				<td>2121321</td>
				<td>2121321</td>
				<td>2121321</td>
				<td>2121321</td>
				</tr>
				<tr>
				<td>2121321</td>
				<td>2121321</td>
				<td>2121321</td>
				<td>2121321</td>
				<td>2121321</td>
				<td>2121321</td>
				<td>2121321</td>
				</tr>
				<tr>
				<td>2121321</td>
				<td>2121321</td>
				<td>2121321</td>
				<td>2121321</td>
				<td>2121321</td>
				<td>2121321</td>
				<td>2121321</td>
				</tr>
				<tr>
				<td>2121321</td>
				<td>2121321</td>
				<td>2121321</td>
				<td>2121321</td>
				<td>2121321</td>
				<td>2121321</td>
				<td>2121321</td>
				</tr>

				
			</tbody>
		</table>
	</div>

</body>
</html>

Open in new window

kumar naikGraphic DesignerAsked:
Who is Participating?
 
Julian HansenCommented:
how to remove if it is an ID border   not class border
$(e).closest('#border').removeClass('border');

Open in new window

how to write if the table is in the display:none position. not in hidden
:hidden applies to display: none not to visibility:hidden
0
 
Julian HansenCommented:
<script>
$(function(){
	if ($('.border table:visible').length == 0) {
		$('.border').removeClass("border")
	}
})
</script>

Open in new window

0
 
Julian HansenCommented:
Another version
<script>
$(function(){
	$('table:hidden').each(function(i, e) {
		$(e).closest('.border').removeClass('border');
	})
})
</script>

Open in new window

0
Ultimate Tool Kit for Technology Solution Provider

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy now.

 
kumar naikGraphic DesignerAuthor Commented:
how to remove if it is an ID border   not class border
0
 
kumar naikGraphic DesignerAuthor Commented:
how to write if the table is in the display:none position. not in hidden
0
 
kumar naikGraphic DesignerAuthor Commented:
sorry forgot to close solution was very helpful thanku
0
 
Julian HansenCommented:
You are welcome.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.