Updated fiddle: https://jsfiddle.net/sne40vh1/3/
The main problem was that you were trying to set the height of #button
without a unit of measurement (jQuery's .height method returns only a value, no measurement) so when you were trying to set the style in the vanilla JavaScript, which requires a unit of measurement, it was failing (so in this case it would've needed '300px' but you were just giving it '300'.
I've changed it here to have a global function (which isn't recommended, I only did this for the fiddle to work) and changed the way you were setting the height of #button
to match the way you were getting the height of #a
:
HTML:
<div id="a" onclick="changeHeight()"></div>
<div id="button"></div>
CSS:
#a{width:300px;height:100px;background-color:black;}
#button{width:300px;background-color:green;}
JS:
changeHeight = function() {
var divHeight = $("#a").height();
$('#button').height(divHeight);
}
Feel free to compare what i've done with what you had in the first place in order to see my changes better.