我有一個非常基本的功能,我使用jQuery將某些內容(從左到右)或返回(從右到左)滑動。下面的代碼工作,但是,我現在要做的是在我的「overDiv」結尾包含「+」,並使其始終顯示。爲了繪製更清晰的圖片,現在如果您將該代碼粘貼到您的編輯器中幷包含Google的jQuery,您將看到單擊「+」可完全消除「overDiv」塊。但是,我想要做的是在「overDiv」塊的末尾放置「+」,這樣當文本從頁面消失時,+就會一直保留下來。希望這是有道理的?jQuery Animate問題
在此先感謝。
<body>
<script language="javascript" type="text/javascript">
$(function() {
// when we click on the a-href id 'togglen', we move the overDiv to the left.
$('#togglen').click(function() {
// simple animation
$('#overDiv').animate({
left: parseInt($('#overDiv').css('left'),10) == 0 ? -$('#overDiv').outerWidth() : 0
});
}); //
});
</script>
<div><a href="#" id="togglen">+</a></div>
<div style="background-color:#CCC; width:180px; position:absolute; left:0; overflow:hidden; float:left;" id="overDiv">Lorem ipsum.</div>
http://jsfiddle.net/S5RFT/例如,我估計'+'在10px的寬度 – Fresheyeball
這正是我在尋找。感謝所有回答的人。謝謝,Fresheyeball ..真的很感激它。 –