当前位置: 动力学知识库 > 问答 > 编程问答 >

javascript - Get width from other element to set to current element but not equals in jQuery

问题描述:

I have a input. I want my div when I append it, it has same width of input. Here my code.

$("#search-result").width($("#searchForm").width());

But $("#search-result")'width not equals $("#searchForm")'s width. I try to debug it in Chrome inspect element.

But it's gerenate to HTML like this:

Why? Is there any solution to make same width? Thanks

网友答案:
var searchWidth = $("#searchForm").width() + 'px';
$("#search-result").css('width', searchWidth );
分享给朋友:
您可能感兴趣的文章:
随机阅读: