0
我不熟悉Javascript。我一直在試圖弄清楚,但現在我卡住了...根據窗口縱橫比更改src值
我有一個背景滑塊,根據窗口大小不保留其原始方面。避免太多失真,例如在縱向模式下的Ipad。我認爲當窗口的高度大於寬度時,我會爲滑塊使用另一個圖像源。 這是我到目前爲止有:
if(window.innerHeight > window.innerWidth){
document.getElementById('threesixty').attr('dataPath','path/to/imagesIpad{index}.jpg');
}
else {
$('.threesixty').attr('data-path','path/to/images{index}.jpg'); }
和這裏的什麼是在html
<div class="threesixty" data-path="path/to/images{index}.jpg" data-count="72">
但這並不工作...