Yeats Yeats - 6 months ago 10
Javascript Question

Why is innerHTML returning 'undefined'?

I'm trying to catch the "value" inside this div, which is editable:

<div class="editable-div" contentEditable="true">Hey</div>


I figured I could do this simply via JavaScript:

var changedText = $('.editable-div').innerHtml


However, this variable will always return "undefined", which confuses me.

Can someone enlighten me on how to reach this "value"?

Answer

It is jQuery - you have to use:

$('.editable-div').html()
Comments