打赏

jquery实现元素高度变化页面变化

试了几种方法包括有资料说的h5新特性,都没能满足我的需求。我的需求如下:

元素高度是动态可变的,比如可拖动teatarea元素

 

最后用到了指针监听事件解决了

@参考文档

 

$(document).mousemove(function(e){

//这一块处理页面高度

});

 示例:

$(document).mousemove(function(e){
    var height="";
    $($("body div").children()).each(function(index,item){
        height+=$(item).height();
    });
    $('#replaceContent', parent.document).height(height);
});
View Code
<body>
    <div>
        <form id="form">
            <table>
                <tr><td><textarea rows="" cols=""></textarea></td></tr>
            </table>
            </form>
    </div>
</body>
View Code

 

定义和用法

当鼠标指针在指定的元素中移动时,就会发生 mousemove 事件。

posted @ 2018-10-30 09:48  每天都要学一点  阅读(1079)  评论(0编辑  收藏  举报