怎么监听一个div的宽度改变
1个回答
展开全部
给你推荐一个jquery重新封装resize代码,可以监听几乎所有html标签,比如text、p、div、span等。$(function(){
// Bind the resize event. When any test element's size changes, update its
// corresponding info div.
$('.test').resize(function(){
var elem = $(this);
// Update the info div width and height - replace this with your own code
// to do something useful!
elem.closest('.container').find('.info')
.text( this.tagName + ' width: ' + elem.width() + ', height: ' + elem.height() );});// Update all info divs immediately.
$('.test').resize();
// Add text after inline "add text" links.
$('.add_text').click(function(e){
e.preventDefault();
$(this).parent().append( ' Adding some more text, to grow the parent container!' );});// Resize manually when the link is clicked, but only for the first paragraph.
$(this).parent().resize();});});看一下官方介绍吧,里面有几个例子!jquery resize event
// Bind the resize event. When any test element's size changes, update its
// corresponding info div.
$('.test').resize(function(){
var elem = $(this);
// Update the info div width and height - replace this with your own code
// to do something useful!
elem.closest('.container').find('.info')
.text( this.tagName + ' width: ' + elem.width() + ', height: ' + elem.height() );});// Update all info divs immediately.
$('.test').resize();
// Add text after inline "add text" links.
$('.add_text').click(function(e){
e.preventDefault();
$(this).parent().append( ' Adding some more text, to grow the parent container!' );});// Resize manually when the link is clicked, but only for the first paragraph.
$(this).parent().resize();});});看一下官方介绍吧,里面有几个例子!jquery resize event
本回答被提问者和网友采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
TableDI
2024-07-18 广告
2024-07-18 广告
仅需3步!不写公式自动完成Excel vlookup表格匹配!Excel在线免,vlookup工具,点击53步自动完成表格匹配,无需手写公式,免费使用!...
点击进入详情页
本回答由TableDI提供
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询