Append function is not working when using it after the load function.
$('section article a').on('click',function(e){
e.preventDefault();
id = $(this).attr('class');
$('article[id='+id+']').load( 'articles/'+id+'.html' );
$('article[id='+id+']').append( "<strong> Where am I?<br/>StackOverflow HELP !!!</strong>" ); //This is NOT appended
});
Any idea ?
Try to wait until your load
finish then use append()
instead:
$('article[id='+id+']').load( 'articles/'+id+'.html', function() {
$('article[id='+id+']').append( "<strong> Where am I?<br/>StackOverflow HELP !!!</strong>" );
});
Also you can just use $('#'+id)
instead of $('article[id='+id+']')
since id
is unique.