I'm looking for a function to load content into a page. If I use it this way works fine
$(document).ready(function() {
$('#nav li a').click(function(){
var toLoad = $(this).attr('href')+' #content';
$('#load').remove();
$('#wrapper').append('<span id="load">LOADING...</span>');
$('#load').fadeIn('normal',loadContent);
function loadContent() {
$('#content').append($('<div>').load(toLoad,'',showNewContent()))
}
function showNewContent() {
$('#content').fadeIn('normal',hideLoader());
}
function hideLoader() {
$('#load').fadeOut('normal');
}
return false;
});
});
but when I want to make it function
jQuery.addc = function(){
var toLoad = $(this).attr('href')+' #content';
$('#load').remove();
$('#wrapper').append('<span id="load">LOADING...</span>');
$('#load').fadeIn('normal',loadContent);
function loadContent() {
$('#content').append($('<div>').load(toLoad,'',showNewContent()))
}
function showNewContent() {
$('#content').fadeIn('normal',hideLoader());
}
function hideLoader() {
$('#load').fadeOut('normal');
}
return false;
};
stop working, when I call the function with onclick
<ul id="nav">
<li a href="index.html" onclick="$.addc();"> Index </a> </li>
</ul>
I don't know whats happening because first code works fine, but second don't, If anyone can help me please
I also try $.fn.addc = function () but don't work