jquery通过单击第二页上的按钮更改页面内容

时间:2014-07-03 20:08:29

标签: javascript php jquery html

我有2个php文件和一个jquery文件(2个php文件包含该jquery文件)。如何使用jquery(没有刷新页面)单击2页上的按钮来更改1页的内容。例如:在按钮上单击将div(2页)发送到div(1页)。或者可以使用2个jquery文件或任何其他技术。代码演示将是完美的。我的代码: 的 ex2.php

<script src="ex2.js"></script>
<title>Ex2</title>
</head>

<body>
<button class="show"> show </button>
<div class="showdiv"> show </div>
</body>

ex3.php

<script src="ex2.js"></script>
<title>Ex3</title>
</head>

<body>
<button class="save"> Save </button>
<div class="savediv"> Save </div>
</body>

ex2.js

$(document).ready(function(){
    $(".save").click(function() {
        $(".showdiv").after("<p>GGGGGGGG</p>");

    });
    $(".show").click(function() {
        $(".showdiv").after("<p>BBBBBBBB</p>");
        $(".savediv").after("<p>BBBBBBBB</p>");
    });

});

1 个答案:

答案 0 :(得分:0)

AFAIK这种&#34;推&#34;只有当您有一个涉及服务器端服务的高度复杂的系统和正在侦听这些服务的更改的接收页面上的挂钩时,才有可能。因此,根据StackOverflow指南,这个问题过于宽泛,可能对于简单的答案而言过于复杂。