jQuery的/ AJAX - 内容加载到一个div时,单击按钮? [英] jQuery/AJAX - Load content into a div when button clicked?
本文介绍了jQuery的/ AJAX - 内容加载到一个div时,单击按钮?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
会有人能帮助这里吗?
我想填补一个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');
});
})
这篇关于jQuery的/ AJAX - 内容加载到一个div时,单击按钮?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文