Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/391.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/88.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 打开和关闭包含其他文件的div_Javascript_Jquery_Html - Fatal编程技术网

Javascript 打开和关闭包含其他文件的div

Javascript 打开和关闭包含其他文件的div,javascript,jquery,html,Javascript,Jquery,Html,我有一页 master.html 使用以下脚本: <script type="text/javascript"> $(document).ready(function() { $('a.art').click(function() {var url = $(this).attr('href'); $('#contentart').load(url); $('html,body').animate({scrollTop: parseInt($('

我有一页

master.html

使用以下脚本:

<script type="text/javascript">
$(document).ready(function() {
    $('a.art').click(function() {var url = $(this).attr('href');
        $('#contentart').load(url);
        $('html,body').animate({scrollTop: parseInt($('#contentart').offset().top)}, 'slow');
        $('.show_hide').click(function(){
            $("#contentart").slideToggle();
        });
        return false;
    });
});
</script>

$(文档).ready(函数(){
$('a.art')。单击(function(){var url=$(this.attr('href');
$('#contentart').load(url);
$('html,body').animate({scrollTop:parseInt($('contentart').offset().top)},'slow');
$('.show_hide')。单击(函数(){
$(“#内容艺术”).slideToggle();
});
返回false;
});
});


$(文档).ready(函数(){
$('a[href^=“#“]”)。关于('click',函数(e){
e、 预防默认值();
var target=this.hash,
$target=$(target);
$('html,body').stop().animate({
'scrollTop':$target.offset().top
},900,“摆动”,功能(){
window.location.hash=目标;
});
});
});
在身体里:

<div class="one">
<a class="art" href="file1.html">link</a>
<a class="art" href="file2.html">link</a>
<a class="art" href="file3.html">link</a>
<a class="art" href="file4.html">link</a>
ecc ecc
</div>

ecc ecc
单击这些链接,将在此div中打开相对文件ux.html:

<div style="width: 100%" id="contentart"></div>

带着一段柔和的电影到电影节

在身体里我有这个链接

<a href="#qui"cursor: pointer;" class="show_hide">close the div</a>

为了一个新的选择;此函数关闭div并上升到顶部

但是所有的功能都不能很好地工作:如果我第二次打开链接(ALTRO)时没有打开新的链接,则打开速度很慢。 这里是测试链接:


请告诉我,我需要一个帮助来修复所有内容,因为我不是开发人员。

速度很慢,因为你加载的不仅仅是文本,还有一堆样式表和其他根本不属于正文的内容

您甚至强制重新加载jquery(这是巨大的)。检查单击FireBug网络控制台中的链接时发生的情况

单击链接后将发送所有GET。我不完全理解你的代码,有很多模糊的代码,但它有严重的问题

<a href="#qui"cursor: pointer;" class="show_hide">close the div</a>