jQuery的/ AJAX - 内容加载到一个div时,单击按钮?单击、按钮、加载、内容

2023-09-10 13:34:34 作者:Ramiro 拉米罗

会有人能帮助这里吗?

我想填补一个div例如

I would like to fill a div e.g.

<div id="contenthere"></div>

从外部文件例如内容。

with content from an external file e.g.

/includes/about-info.html

点击例如,使用某一类按钮时

when a button with a certain class is clicked e.g.

<p class="classloader">Click Here</p>

有没有人有一个快速的code例如,它们可以告诉我取悦实现这一目标?

Does anyone have a quick code example they can show me please to achieve this?

非常感谢。

推荐答案

使用 jQuery.click jQuery.load

$(document).ready(function(){
    $('.classloader.').click(function(){
        $('#contenthere').load('/includes/about-info.html');
    });
})