1
我需要一個腳本來確定調整conrol的父元素寬度的大小。這是確定的窗口調整大小事件我需要的是要知道我們父母是比以前更小或比以前更大。請留下工作的例子 - 將apreciated感謝窗口調整大小確定控件父級更小或更大
的JavaScript:
(function ($) {
$.fn.quicklist = function() {
var _this = this;
var config = {
quicklistParentWidth: $(_this).parent().width(),
}
var parentWidth = config.quicklistParentWidth;
$(window).resize(function (event) {
var currWidth = config.quicklistParentWidth;
$(_this).parent().css('width', config.quicklistParentWidth);
if (currWidth > parentWidth) {
$('#width').text('greater');
} else if(parentWidth < currWidth) {
$('#smaller').text('smaller');
}
parentWidth = currWidth;
});
};
})(jQuery);
$(document).ready(function() {
$('#quicklist').quicklist();
});
HTML:
<table border="0" cellpadding="0" cellspacing="0" width="100%">
<tr style="height:34px">
<td style="background:url(images/classic/quicklink_bar.png) 0px 0px; background-repeat:repeat-x; width:100%;">
<ul id="quicklist">
<li><a href="#">List Goes here</a></li>
</ul>
</td>
<td style="background:url(images/classic/quicklink_bar.png) 0px 0px; background-repeat:repeat-x; ">
<a id="link" href="#">Link</a>
</td>
</tr>
</table>
<span id="width"></span>
感謝你的回覆,你可以做jQuery的,我請,所以我可以用它 – ONYX
我用您選擇的樣品,我得到它的工作我設法將其轉換爲jQuery和它的所有好三江源爲你的幫助和時間歡呼 – ONYX
無後顧之憂,幹得好! – gkiely