1

I'm trying to work out if it's possible to detect the change inside a div. With my snippet I'm trying to do an alert when you click click me but it doesn't work. My understanding from jQuery's docs is that you can attach the change handler to an element.

$( "#target" ).change(function() {
  console.log( "change detected" );
});
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>

<div id="target"></div>

<span onclick="$('#target').html('changed')">click me</span>
Daniel Williams
  • 2,195
  • 7
  • 32
  • 53
  • You will need a `MutationObserver` to achieve what you want. The `change` event is only triggered by inputs and so. – Zenoo Apr 13 '18 at 11:37

0 Answers0