In common way developers will write multiple document.ready() functions in same page and they wont care about code coverage, as a programmers i am not talking about all programmers those who still following, those should concentrate to reduce the code as much as possible and it is very good practice to keep all functions
in one group and put it in one file.
now i am showing you one example with multiple document.ready() functions
as above example we can write without using multiple document.ready() functions, see the bellow example
<script> $(document).ready(function(){ $('#btn').click(function(){ alert('hello') } }); $(document).ready(function(){ $('#btn1').click(function(){ alert('hello'); } }); </script>
as above example we can write without using multiple document.ready() functions, see the bellow example
<script> $(function(){ $('#btn').click(function(){ alert('hello') } $('#btn1').click(function(){ alert('hello'); }
});
</script>
here a function passed as an argument to jQuery constructor and it is bound to
the document ready event.
No comments :
Post a comment