Jquery width detection
Jquery width detection
Out of context: Reply #3
- Started
- Last post
- 10 Responses
- sublocked0
This is basic, basic javascript stuff dude.
$(function () {
var win, lazyResize;function handleResize() {
var divWidth = $('#somediv').width();
// now do something with that...
}// debounce is an underscore.js function.
// We debounce so it doesn't fire too many times, taking up
// cycles on the user's computer.
lazyResize = _.debounce(handleResize, 100);
// Hold reference to window for speed.
win = $(window);
// Apply event handler on resizing window...
win.on('resize', lazyResize);
// Call it once to start
lazyResize();
});