search

Home  >  Q&A  >  body text

javascript - How is this content displayed in blocks? Why can't I test it?

How does this single page display content in blocks?

I put it

<script type="text/javascript" src="http://ajax.microsoft.com/ajax/jquery/jquery-1.4.2.min.js"></script>
<script>
$(function(){
    $("#nav a").click(function(){
        href = $(this).attr('href');
        if (href.slice(0, 1)=='#') {
            type = href.slice(1);
            $(".content").fadeOut(350);
            $("#content-" + type).fadeIn(350);
        }
    });
});
</script>
<style>

.content {
    padding-left: 20px;
    display: none;
    position: absolute;
    top: 0;
    left: 0;
}
</style>

Took these two pieces down,
Then my settings are set like this
Navigation

<p id="nav" style="margin-bottom:20px">
    <a href="#product-jichu" class="summary current">基本信息</a>
    <a href="#product-canshu" class="desc">详情</a>
    <a href="#product-pinglun" class="review">评价</a>

</p>

content

<p class="content" id="content-product-info" style="display:block;">
测试页面1
</p>
<p class="content" id="content-product-canshu">
测试页面2
</p>
<p class="content" id="content-product-pinglun">
测试页面3
</p>

Why can't this have the same effect as him?
It was displayed when I opened it, and then everything disappeared after clicking the navigation. Is there anything wrong?

曾经蜡笔没有小新曾经蜡笔没有小新2758 days ago394

reply all(2)I'll reply

  • 漂亮男人

    漂亮男人2017-05-16 13:18:49

    The id suffix of test page 1 is inconsistent with the one in a

    reply
    0
  • 黄舟

    黄舟2017-05-16 13:18:49

    Okay, it’s still my own problem. I don’t know why the content in the script was swallowed by the program

    reply
    0
  • Cancelreply