I add a class to div and want to use this added class as condition, but it seems, that it doesn't work:
Here is the code:
<div class="knock">Knock</div>
<div class="msg">Say hello</div>
$( ".knock" ).click(function() {
$( ".msg" ).addClass( "sayhello" );
});
$( ".msg.sayhello" ).click(function() {
alert("Hello!");
});
The codepen: https://codepen.io/anon/pen/vwEOoa