我对 jquery 有一点问题,我自己无法解决。我有一张图片,当我点击该图片时,会出现一个 div 切换。我希望当 div 隐藏时,图像是向下箭头,而当 div 可见时,图像是向上箭头。我的 HTML 代码:
<div class="small-3 columns log_message">
<span id="mesaj_salutare">Welcome!</span><br>
<span id="account">MY ACCOUNT</span>
<img id="image_log" src="images/down.png"/>
</div>
<div class="small-4 columns" id="log_form">
<?php
//display diffrent code if user is logged or not
if (isset($_SESSION['id_utilizator']) and isset($_SESSION['email_login'])) {
require_once 'page_sections/logout.php';
} else {
require_once 'page_sections/login_form.php';
}
?>
</div>
我的 log_form CSS:
#log_form{
margin-top:18px;
display: none;
min-height: 200px;
border: 1px solid #999999;
position: absolute;
top: 60px;
right: 0;
background: #788dbc;
z-index: 10;
-webkit-border-bottom-right-radius: 10px;
-webkit-border-bottom-left-radius: 10px;
-moz-border-radius-bottomright: 10px;
-moz-border-radius-bottomleft: 10px;
border-bottom-right-radius: 10px;
border-bottom-left-radius: 10px;
font-size: small;
min-height: 150px;
}
我的 jQuery 代码:
$(document).ready(function (){
$("#image_log").click(function(){
$("#log_form").toggle(500);
});
});
所以让我们回顾一下:当页面开始时#log_form
隐藏并且#image_log
src is= "images/down.png"
,点击后#image_log
出现#log_form
,我需要那个#img_log
src 是="images/up.png"