我正在顯示和隱藏包含文本的div,以便能夠看到背後的背景圖像。我被扶上很讓我的div只是動了一下,並讓我的DIV可見一側有沒有辦法顯示/隱藏在顯示和隱藏同一個div的圖像切換
$("#welcome").toggle(
function() {
var left = $(this).outerWidth() - 10 + "px";
$(this).animate({ "margin-left": "+=" + left }, 500);
$(this).onClick() },
function() {
var left = $(this).outerWidth() - 10 + "px";
$(this).animate({ "margin-left": "-=" + left }, 500);
}
);
現在我想我的HTML圖像改變形式隱藏顯示...
<div id="welcomepicture">
<div id="welcome">
Welcome some really meaningful text here!
<p class="arrowfull"><a href="#"> <img class="img-swap" src="http://housing.ucsc.edu/guide/css/images/hide_off.png" alt="Click to view full image" title="Click to view full image" height="42" width="17"> </a></p>
我不確定是否在JavaScript中,如果我把.onClick圖像交換?或者我寫一個新的變種? 新來的jQuery和JavaScript,感謝您的幫助
http://jsfiddle.net/BeccaAlley/UfsS8/4/
我認爲我做錯了沒有.attr在我的代碼中,謝謝佩德羅的幫助。 –
沒問題。快樂的編碼! –