简体   繁体   English

使用Javascript在同一面板上显示不同的内容。

[英]Displaying different content on the same panel using Javascript.

I have a list of anchor tags on a website. 我在网站上有一个锚标签列表。 How can I change the content of a panel depending on which tag is clicked. 如何根据单击的标签来更改面板的内容。 I don't want the page to change. 我不想更改页面。 I am guessing I will need to use JQuery but I don't want to use tabs. 我猜我将需要使用JQuery,但我不想使用选项卡。 Please help. 请帮忙。 Thank you. 谢谢。

When Anchor Clicked Trigger this to pull new panel, test.php would do the work. 当“锚点”单击“触发此”以拉出新面板时,test.php将完成工作。 then just insert the returned html. 然后只需插入返回的html。

You will have to include jQuery library 您将必须包括jQuery库

$.post("test.php", { PanelNum: Num},
   function(data) {
     $("#panel").html(data)
   });
$(document).ready(function() {
    $('a').click(function(event) {
        event.preventDefault(); 
        **code to change panel content, whether it be an 
        ajax request or simple $('selector').html()**
    });
});

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM