cc
is not a global function.
It is defined with a function declaration, so it is scoped to the function it is defined in.
That function is the anonymous one that you pass to the ready
method. (And you do that inside a function that you run onload
due to your jQuery configuration).
Globals are (in general) something to be avoided as much as possible, and intrinsic event attributes usually depend on them.
Don't use intrinsic event attributes. Bind your JavaScript event handlers using JavaScript. Since you are using jQuery, use the on
method.
$(document).ready(function(){
function cc(){
$('div').css('color','red');
};
$('button').on('click', cc);
});
demo