我試圖通過AutoSponge
而不是使用<input type="checkbox" ... />
觸發事件的撰寫http://www.endusersharepoint.com/2008/12/22/jquery-for-everyone-cleaning-windows-pt2/SharePoint 2007的坍縮區域功能
代碼擴大,我想使用
<input type="image" class="toggleClass" id="LeftRight"
value="tr:lt(9)" src="../../img/topcollapse.jpg" />
和
<input type="image" class="toggleClass" id="UpDown"
value="#TitleAreaImageCell, #LeftNavigationAreaCell"
src="../../img/leftcollapse.jpg" />
來觸發該功能。崩潰函數有效,但img源不會更改。我認爲我沒有正確地調用它,但我一直無法弄清楚爲什麼。提前感謝您的幫助。
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
<script type="text/javascript">
//initialize checkboxes
$(function() {
$("input.toggleClass:image").each(function (i, e) {
var v = e.value;
var g = GetCookie(v); //SP function
var src = ($("#UpDown").attr("src") === "img/up_arrow.bmp")
if (g == "1") {
e.checked = true;
$(v).hide();
}
});
});
//set cookie on click and hide element
$(function() {
$("input.toggleClass:image").click(function (e) {
var v = $(e.target).val();
var g = GetCookie(v);
if (g == "1") {
$(v).show();
SetCookie(v, "", "/"); //SP function
} else {
$(v).hide();
SetCookie(v, "1", "/");
}
});
});
$(document).ready(function() {
$("#UpDown").bind("click", function() {
var src = ($("#UpDown").attr("src") === "../../img/topcollapse.jpg")
? "../../img/downcollapse.jpg"
: "../../img/topcollapse.jpg";
$("#UpDown").attr("src", src);
});
});
$(document).ready(function() {
$("#LeftRight").bind("click", function() {
var src = ($("#LeftRight").attr("src") === "../../img/leftcollapse.jpg")
? "../../img/rightcollapse.jpg"
: "../../img/leftcollapse.jpg";
$("#LeftRight").attr("src", src);
});
});
</script>
</head>
<body>
<form id="form1" runat="server">
<div>
<input type="image" class="toggleClass" id="UpDown" value="#TitleAreaImageCell, #LeftNavigationAreaCell" src="img/leftcollapse.jpg" /><br /><br />
<input type="image" class="toggleClass" id="LeftRight" value="tr:lt(9)" src="img/topcollapse.jpg" />
</div>
</form>
</body>
</html>
出於測試的目的,我除去toggleClass功能和離開#LeftRight和#UpDown功能。它在短時間內工作,但頁面會刷新並恢復。是否.blind(「點擊」)這樣做? – Austin 2011-05-23 18:07:16
我已經測試了input.toggleClass:圖像,它的工作原理。 #UpDown和#LeftRight在瞬間工作,導致屏幕在恢復之前閃爍(在FireFox中測試)。我會在這裏留下筆記以協助任何決定提供幫助的人。謝謝。 – Austin 2011-05-24 16:44:53