I need to find and replace a div with the id left_s with a div with id=newdiv. Also, I need to get the height and width of the previous div left_s and apply it to the new div with id=newdiv.
I’ve got this code, but it’s not working:
$('#left_s').replaceWith('<div id="newdiv" </div>');
var w = $("#newdiv").width();
$(".left_s").width(w);
///////after “.replaceWith” i can’t get height and width from div “left_s” and apply it to “newdiv”.
Try:
You can fix up the code so it matches your purpose, but the key is appending the element into the DOM. Otherwise, it doesn’t have a computed width/height.