Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to use the different image by PC and mobile? #811

Closed
sutara79 opened this issue May 12, 2015 · 2 comments
Closed

How to use the different image by PC and mobile? #811

sutara79 opened this issue May 12, 2015 · 2 comments
Labels

Comments

@sutara79
Copy link

Hi,
I want to use the different image by PC and mobile.
I made a example like following.
Is this a right way?
Are there suitable ways or options?
Thanks.


http://runnable.com/VVFeVAp77bh6VUBr/how-to-use-the-different-image-by-pc-and-mobile-on-jquery-bxslider-js

JavaScript
function changeSlider() {
    if (window.innerWidth < 800) {
        $('.bx-wrapper:has(#slider-pc)').hide();
        $('.bx-wrapper:has(#slider-mobile)').show();
    } else {
        $('.bx-wrapper:has(#slider-pc)').show();
        $('.bx-wrapper:has(#slider-mobile)').hide();
    }
}
window.onload = function () {
    var slider = $('.bxslider').bxSlider({
        onSliderLoad: changeSlider,
        onSliderResize: changeSlider
    });
};

001
002

@Tidal-Wave
Copy link
Collaborator

Overall this is an ok way to do this, but Its bad practice to use id's more than once on a page, so if you have multiple #slider-pc or #slider-mobile that's semantically bad. It would be best to use classes.

There is no built in method to do this in bxSlider. There are several ways to achieve this and no real 'wrong' answer, just be sure to consider best practices and efficiency.

@sutara79
Copy link
Author

Oh, thank you.
I understand.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants