javascript - Why "click on document" is not triggering for <a> elements in jQuery datepicker? -
on clicking on link , box, event triggered appropriately on clicking on date in datepicker nothing happening although each date has class "ui-state-active" (date's class can checked in console).
below executable snippet
$(document).ready(function(){ $("#date").datepicker(); $(document).on('click',function(event){ var clickover=$(event.target); if(clickover.hasclass("box")){ $("#box").text("on box"); } else if(clickover.hasclass("link")){ $("#box").text("on link"); } else if(clickover.hasclass("ui-state-active")){ $("#box").text("on date"); } }); });
#box{ height:100px; width:100px; border:2px solid green; }
<!-- latest compiled , minified css --> <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css"> <!-- jquery library --> <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script> <!-- latest compiled javascript --> <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script> <!-- font montserret --> <link href="https://fonts.googleapis.com/css?family=montserrat:100,400,500" rel="stylesheet"> <!-- custom js file --> <script type="text/javascript" src="js/en1_page.js"></script> <!-- use jquery ui below 2 required --> <!-- jquery css --> <link href="https://ajax.googleapis.com/ajax/libs/jqueryui/1.11.1/themes/sunny/jquery-ui.css" rel="stylesheet"> <!-- jquery-ui.js library --> <script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jqueryui/1.11.1/jquery-ui.min.js"></script> <a href="#" class="link1 link">link</a> <div class="box" id="box"></div> <div id=date></div>
Comments
Post a Comment