我想根据窗口宽度(加载和调整大小)更改 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。
在另一篇文章的帮助下,我可以使用此脚本更改我需要的 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);
});
但我还需要即时更改 jQuerystartheight
值。