开发者

what happens if we bind the same div twice one in js file and one as inline script

开发者 https://www.devze.com 2023-01-29 08:38 出处:网络
this is inside javascript file what happenes if i have the same bindings for the same div defined twice //

this is inside javascript file

what happenes if i have the same bindings for the same div defined twice //

$(document).ready(开发者_如何学Gofunction() {     

    $("#divid").click(function() {
     // some logic here

 });
    });

this is as inline

<script language="javascript" type="text/javascript">
$(document).ready(function() {  
  $("#divid").click(function() {
// some logic here
});
 });

</script>


The result will be that both handlers will run, in the order they were bound (unless the first interrupts the event, e.g. return false).

The order they're bound is the order the <script> elements occur in, since .ready() handlers are also queued in order.

0

精彩评论

暂无评论...
验证码 换一张
取 消