CSS 사이를 전환하려면 사용자가 버튼 (# more1)을 클릭하면 CSS가 변경되고 버튼 (# more1)을 다시 클릭하면 CSS가 원본으로 돌아갑니다. jQuery가 CSS 재설정을 전환 하시겠습니까?
$(document).ready(function() {
$("#more1").click(function() {
$("#box").toggle(),
$(".second").css("background-color", "#9EACB7");
$(".second").css("color", "white");
$("#more1").css("background-color", "#9EACB7");
$("button").css("background-color", "#9EACB7");
$("button").css("color", "white");
$("button").css("border-color", "white");
$("#more1").css("color", "white");
});
});
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<table>
<tr>
<th class=firstth><input type="checkbox"></th>
<th class=firstth>User ID</th>
<th class=firstth>User name and Image</th>
<th class=firstth>Phone Number</th>
<th class=firstth>Last Transaction</th>
<th class=firstth>Balance</th>
<th class=firstth>Status</th>
<th class=firstth>Actions</th>
</tr>
<tr>
<td class="second"><input type="checkbox"></td>
<td class="second">#33225</td>
<td class="second"><img class="Profilepic" src="https://www.sophiegee.com/wp-content/uploads/square-face-59592.jpg" align="center"></img>Alfreds</td>
<td class="second">Maria Futterkiste</td>
<td class="second">086265666222</td>
<td class="second">$3552</td>
<td class="second"><button>Active</button></td>
<td class="second"><i class="fa fa-plus-circle" aria-hidden="true" id=more1></i></td>
</tr>
<th colspan="8">
<div id=box></div>
</th>
<tr>
<td><input type="checkbox"></td>
<td>#25526</td>
<td><img class="Profilepic" src="https://s-media-cache-ak0.pinimg.com/736x/ab/74/5f/ab745f93d3ced17005728d939b7e6afc.jpg" align="center"></img>Maria</td>
<td>Alfreds Futterkiste</td>
<td>08606060555</td>
<td>$3663</td>
<td><button>Active</button></td>
<td><i class="fa fa-plus-circle" aria-hidden="true" id=more></i></td>
</tr>
</table>
*{
background-color: #E8EDF2;
}
table{
position: absolute;
margin-left: 200px;
border-collapse: collapse;
}
.firstth, td{
padding: 10px;
border-bottom: 1px solid #A5A5A5;
}
.firstth{
background-color: #9EACB7;
}
td{
background-color: White;
position:static;
}
.Profilepic{
width:42px;
height:42px;
margin-right:10px;
border-radius : 90px;
margin-top: -2px;
}
button{
background-color: #CEF2CE;
color: #339B08;
border: 1px solid #339B08;
border-radius:20px;
font-family : Tahoma;
font-size: small;
width: 90px;
height: 30px;
}
#box{
background : #3C4554;
height : 136px;
display:none;
}
th{
color: white;
font-family: Helvetica;
font-size: small;
}
#more1, #more{
background-color: white;
color: #109BE8;
padding-left: 20px;
}
아직 토글 클래스를 사용할 수 없습니다. 저에게 쓸 수 있습니까? –
편집 : 더 좋은 예입니다. https://codepen.io/atwright147/pen/HEfDu이 방법을 사용하면 코드가 아닌 스타일 섹션에 CSS를 작성할 수 있습니다. 예제는 따라하기 쉽습니다. – Vbudo
나는 css 파일에 ID를 추가 할 수 있으며이 $ ("# box")처럼 호출 할 수 있습니다. toggleClass ('# more1 #moreclass'), –