我想基於窗口寬度(加載和調整大小)更改jQuery選項。基於窗口寬度動態更改jQuery滑塊選項
我發現解決方案接近我所需要的,但我不明白jQuery或JavaScript足以根據我的需要定製它們。
這裏是我的jQuery代碼:
<script type="text/javascript">
var tpj = jQuery;
tpj.noConflict();
tpj(document).ready(function() {
if (tpj.fn.cssOriginal != undefined) tpj.fn.css = tpj.fn.cssOriginal;
tpj('#rev_slider_1_1').show().revolution({
delay: 5000,
startwidth: 1920,
startheight: 515,
hideThumbs: 200,
thumbWidth: 100,
thumbHeight: 50,
thumbAmount: 4,
navigationType: "bullet",
navigationArrows: "verticalcentered",
navigationStyle: "navbar",
touchenabled: "on",
onHoverStop: "off",
navOffsetHorizontal: 0,
navOffsetVertical: 20,
shadow: 0,
fullWidth: "on"
});
}); //ready
</script>
我想改變startheight
基於窗口的寬度。
如果窗口寬度高於1280,我希望高度的值爲515,如果低於1280,我希望高度爲615,如果寬度小於480,則高度爲715。
從另一個post幫助我能夠改變我需要使用這個腳本的CSS:
$(window).on('load resize', function() {
var w = $(window).width();
$("#rev_slider_1_1 #rev_slider_1_1_wrapper")
.css('max-height', w > 1280 ? 515 : w > 480 ? 615 : 715);
});
但我還需要在運行中改變了jQuery startheight
值。
是的,我相信如此。 – Nathan