I'm loading content into several divs with
我正在将内容加载到几个div中
ajax_loadContent
ajax_loadContent
<div class="content"><div class="container" id="contents2"><!-- Empty div for dynamic content -->Loading content. please wait...</div><script type="text/javascript">ajax_loadContent('contents2','http://www.thewebsite.com/blank.php');</script></div>
Basically, I don't want to load anything until the user clicks on the links I have specified to load content into these instances, please help! Right now, I'm loading a blank file to show nothing in the div.
基本上,我不想加载任何东西,直到用户点击我指定的链接将内容加载到这些实例中,请帮忙!现在,我正在加载一个空白文件,以便在div中显示任何内容。
1 个解决方案
#1
1
Your function is being called inside the <script>
tags, so it's going to run as soon as the javascript is loaded.
你的函数是在
Using jQuery, run the function only when elements with the id "link_id" are clicked.
使用jQuery,仅在单击id为“link_id”的元素时运行该函数。
$(document).ready(function() {
$("#link_id").click(function() {
ajax_loadContent('contents2','http://www.thewebsite.com/blank.php');
});
});
or using a non jQuery method:
或使用非jQuery方法:
<a href="javascript:ajax_loadContent('contents2','http://www.thewebsite.com/blank.php')">clickme</a>
or
要么
<a href="" onClick="ajax_loadContent('contents2','http://www.thewebsite.com/blank.php');return false;">click me</a>
#1
1
Your function is being called inside the <script>
tags, so it's going to run as soon as the javascript is loaded.
你的函数是在
Using jQuery, run the function only when elements with the id "link_id" are clicked.
使用jQuery,仅在单击id为“link_id”的元素时运行该函数。
$(document).ready(function() {
$("#link_id").click(function() {
ajax_loadContent('contents2','http://www.thewebsite.com/blank.php');
});
});
or using a non jQuery method:
或使用非jQuery方法:
<a href="javascript:ajax_loadContent('contents2','http://www.thewebsite.com/blank.php')">clickme</a>
or
要么
<a href="" onClick="ajax_loadContent('contents2','http://www.thewebsite.com/blank.php');return false;">click me</a>