JavaScript resize 得到错误的值,求助

dxcqcv · December 02, 2014 · 1606 hits

我取 window 的宽度,减掉点什么,然后放大缩小浏览器,再点击 p 标签会得到 2 个值,一个正确的,一个错误的,为什么?

html 代码如下

click me get value

js 代码如下

(function(){

test();

$(window).resize(function(){ test(); });

}());

function test() { var t = $(window).width()-74; alert('one ' +t); $(document).on('click', '.test',{t: t}, get); } function get(event) { var l = event.data.t alert('two ' +l) } jsfiddle 地址 http://jsfiddle.net/dxcqcv/xetbhwpv/1/

No Reply at the moment.
You need to Sign in before reply, if you don't have an account, please Sign up first.