欢迎各位兄弟 发布技术文章
这里的技术是共享的
console.log($(this).css('width')); //带像素 px
console.log($(this).width());//不带像素 px
$("p").width(200);//不带像素 px
$("p").css('width','200px');//带像素 px
下面带像素
var left = $('#test').css('left'); var top = $('#test').css('top');
下面获取不带像素
var left = $('#test').position().left; var top = $('#test').position().top;
下面的设置不带像素 设置成百分比 见 /node-admin/12948
$("#mydiv").parent().css({position: 'relative'});
$("#mydiv").css({top: 200, left: 200, position:'absolute'});
console.log("height" + $('#' + old_id).css('height'));
console.log("height()" + $('#' + old_id).height());
console.log("outerheight" + $('#' + old_id).outerHeight());
console.log("innerheight" + $('#' + old_id).innerHeight());
由此可见 只有 css('height') 才看到 px