user379888
user379888

Reputation:

Change width to full width in JavaScript

I have the following code in JavaScript. I need to increase the width to full width. In CSS I can do it by writing width:100%. How do I write it in JavaScript? Please guide. Thanks.

jQuery(document ).ready(function( $ ) {
        jQuery('#example3' ).sliderPro({
            width:1250,
            height:400,
            fade: true,
            arrows: true,
            buttons: false,
            fullScreen: true,
            shuffle: true,
            thumbnailArrows: true,
            autoplay: false
        });
    });

Upvotes: 0

Views: 1604

Answers (3)

herriekrekel
herriekrekel

Reputation: 571

Sinse you're using slider pro 100% should be possible so width: '100%'

this is what it says on their page:

width: Sets the width of the slide. Can be set to a fixed value, like 900 (indicating 900 pixels), or to a percentage value, like '100%'. It's important to note that percentage values need to be specified inside quotes. For fixed values, the quotes are not necessary. Also, please note that, in order to make the slider responsive, it's not necessary to use percentage values. Default value: 500

Upvotes: 3

Tejas
Tejas

Reputation: 711

Javascript doesn't understand units like px or % right out of the box. You'll want to write width: window.innerWidth in your code snippet on line 3. That's Javascript for "the size of the window".

Upvotes: 0

Bikas
Bikas

Reputation: 2759

CSS width:100% is equivalent to jQuery(element).css('width', '100%'); for single property or

jQuery(element).css({
    'width': '100%'
});

for multiple properties.

Upvotes: 0

Related Questions