I am using displayRows() function to add table body using document.ready. It was working fine for syntax : $(document).ready(function() as below
`$(document).ready(function() {
function displayRows(){
var catRow = $(”
- ”
+……….. - ” + ”);
$(‘#cat tbody’).append(catRow);
}
});`
But when I removed the function() as below, the table is not getting appended.
`$(document).ready(
function displayRows(){
var catRow = $(”
- ”
+……….. - ” + ”);
$(‘#cat tbody’).append(catRow);
}
});`
Can anyone explain why it’s not working in below case.
I expect it should work in same in both cases. As document.ready() require a function to be passed in it. And displayRows() function is still passed as a function to document.ready in second case.