javascript - JQuery event dosen't work after .addClass -
why div#1 dosen't change text. i'm doing wrong?
<div id="1" class="a" style="width: 300px;height: 300px; background-color: #003366"></div> <div id="2" class="b" style="width: 300px;height: 300px; background-color: #003366"></div> <script> $(document).ready(function(){ $(".b").click(function(){ $(this).text("hello"); }); $(".a").mouseover(function(){ $(this).addclass("b"); }); }); </script>
try
$("body") .on('click', '.a', function (){ $(this).addclass("b"); }) .on('click', '.b', function (){ $(this).text("hello"); })
Comments
Post a Comment