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

262
December 10, 2016, at 2:38 PM

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

Answer 1
var searchWidth = $("#searchForm").width() + 'px';
$("#search-result").css('width', searchWidth );
READ ALSO
Modify checkbox change() event to wait for other actions

Modify checkbox change() event to wait for other actions

I have a pretty big list of checkboxes that all perform an action when you check/uncheck one:

271
Remove dot from text generated in javascript

Remove dot from text generated in javascript

I found a code that i need for a site but it is not exactly what i want ( change font size after decimal point)

326
using jQuery to edit an sql record

using jQuery to edit an sql record

i am trying to load into a form an existing data from a database, and allow the user to edit and update itbut for some reason, when the edited data is sent by ajax, all the fields are empty

232
Redirect visitors to different places after a certain view count

Redirect visitors to different places after a certain view count

I would like to be able to redirect brackets of viewers to different versions of my homepage, so for example:

178