I am trying to using a variable in the register method of enquire.js. I'm going to be reusing enquire in a few different places in my javascript file, so I would like to be able to manage the widths it is using easier.
This is the basic call
enquire.register("screen and (max-width:860px)", {
});
This is sort of what I was hoping I could do but it's not working.
var $small = '600px';
enquire.register("screen and (max-width:'$small')", {
});
Ah. Me being stupid and forgetting how concatenating works. I needed to end the string with the same type of quotes and then use the plus symbol to concatenate the variable. I then used the same quotes again to finish open and close the remainder of the string.
var $small = '600px';
enquire.register("screen and (max-width:" + $small + ")", {
});
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.