假设投资组合内容在portfolio.html
:
$('#tabcontent2').click(function(e){
$('#content_1').hide();
$("#content_2").show()
// grab portoflio.html and place its contents within #content_2
.load('portfolio.html');
e.preventDefault();
});
您甚至可能想要使用data-*
属性,这样您就不会重新加载页面(获取一次):
$('#tabcontent1').click(function(e){
$('#content_2').hide();
$('#content_1').show();
e.preventDefault();
});
$('#tabcontent2').click(function(e){
$('#content_1').hide();
var $content2 = $("#content_2").show();
// check if it's been loaded before
if (!($('#content_2').data('loaded') || false)){
// grab portoflio.html and place its contents within #content_2
$content2.load('portfolio.html', function(){
// set the flag to say we've already loaded this content
$content2.data('loaded',true);
});
}
e.preventDefault();
});