简体   繁体   中英

How do I use the Materialize Mediabox component

I would like to implement the slider on this page: http://materializecss.com/media.html

I copied the initialization script with my chosen input as so:

<script>
var elem = document.querySelector('.slider');
var instance = M.Slider.init(elem, inDuration:180);
</script>

And pasted at the end of my body. The page does not display anything even when using the example html code provided. What I am doing wrong? Thanks

You are directly giving value to the options parameter. Instead of that, first declare that option, give it a desired value, and then use it in the function, like this:

var elem = document.querySelector('.slider');
var height = 500;
let inDuration = 1800;
var instance = M.Slider.init(elem, inDuration);

If you want to see a working demo, you can find it on my codepen .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM