Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/css/32.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_Css_Ajax_Html_Hyperlink - Fatal编程技术网

Javascript 如何在div中打开链接?

Javascript 如何在div中打开链接?,javascript,css,ajax,html,hyperlink,Javascript,Css,Ajax,Html,Hyperlink,我试图在某个div中打开3个链接。我知道ajax可以帮助我做到这一点,但无论出于什么原因,我都无法让它正常工作。(我对ajax和javascript都是新手)如果有人能帮我,我将不胜感激! 我四处寻找我的问题,似乎找不到任何有用的信息。至少没有达到我需要的程度 <div id="tickcontain"> <div id="ticker"><ul class="bxslider"> <li><img src="../i

我试图在某个div中打开3个链接。我知道ajax可以帮助我做到这一点,但无论出于什么原因,我都无法让它正常工作。(我对ajax和javascript都是新手)如果有人能帮我,我将不胜感激! 我四处寻找我的问题,似乎找不到任何有用的信息。至少没有达到我需要的程度

<div id="tickcontain">
    <div id="ticker"><ul class="bxslider">
        <li><img src="../images/01.png" /></li>
        <li><img src="../images/02.png" /></li>
        <li><img src="../images/03.png" /></li>
        <li><img src="../images/04.jpg" /></li>
    </ul></div>
<div id="calender"><center><?php include ("sources/status.php");?></center></div>

<div id="hallofame"> //**Want the information to load here**// </div>

//**要在此处加载信息**//


注册//**希望这3个成为我的链接**//
Events//**希望这3个链接成为我的链接**//
更新//**希望这3个链接成为我的链接**//
我已将其插入我的标题(页面顶部):


我希望链接/div发生在页面上。(仅尝试测试第一个链接。)


源代码中没有链接。让我们添加它们并更改它们的默认行为:

<a data-target="#halloffame" href="pages/register.php">Register</a>
<a data-target="#halloffame" href="pages/events.php">Events</a>
<a data-target="#halloffame" href="pages/updates.php">Updates</a>

<div id="halloffame"></div>

<script>
  $('[data-target]').click( function (e) {
    var target = $($(this).attr('data-target'));
    target.load($(this).attr('href'));

    e.preventDefault(); // prevent anchor from changing window.location
  });
</script>

$(“[数据目标]”)。单击(函数(e){
var target=$($(this.attr('data-target'));
target.load($(this.attr('href'));
e、 preventDefault();//防止锚点更改window.location
});

源代码中没有链接。让我们添加它们并更改它们的默认行为:

<a data-target="#halloffame" href="pages/register.php">Register</a>
<a data-target="#halloffame" href="pages/events.php">Events</a>
<a data-target="#halloffame" href="pages/updates.php">Updates</a>

<div id="halloffame"></div>

<script>
  $('[data-target]').click( function (e) {
    var target = $($(this).attr('data-target'));
    target.load($(this).attr('href'));

    e.preventDefault(); // prevent anchor from changing window.location
  });
</script>

$(“[数据目标]”)。单击(函数(e){
var target=$($(this.attr('data-target'));
target.load($(this.attr('href'));
e、 preventDefault();//防止锚点更改window.location
});

为什么将所有问题文本都加粗?“无法使其工作”不是问题描述。请描述您的问题。为了便于查看,我的问题是,它没有发送代码以使div按钮可点击,也没有将消息发送到定向div以打开其中的文件。
?为什么将所有问题文本都加粗?“无法使其工作”这不是问题描述。请描述您的问题。为了便于查看,我的问题是,它没有发送代码以使div按钮可点击,也没有将消息发送到定向div以打开其中的文件。
?然后如何打开父div中“pages/register.php”中的一个链接?我现在被困在这一点上:(那么你如何打开父div中“pages/register.php”中的一个链接?我现在被困在这一点上:(
<script type=text/javascript"> 
    $("#tab1").click(function(){
        $("#hallofame").load('pages/register.php');
    });
</script>
<a data-target="#halloffame" href="pages/register.php">Register</a>
<a data-target="#halloffame" href="pages/events.php">Events</a>
<a data-target="#halloffame" href="pages/updates.php">Updates</a>

<div id="halloffame"></div>

<script>
  $('[data-target]').click( function (e) {
    var target = $($(this).attr('data-target'));
    target.load($(this).attr('href'));

    e.preventDefault(); // prevent anchor from changing window.location
  });
</script>