简体   繁体   English

如何在单击按钮时从第 1 页的第 2 页加载代码?

[英]How to load the code from page 2 on page 1 when the button is clicked?

code page1.html:代码页 1.html:

<script class="scriptthis">
some code
</script>
<div id="content">
<div class="card"></div>
<div class="card"></div>
<div class="card"></div>
<div class="card"></div>
</div>
<button id="load-more">Load More Button</button>
<script>
$( "#load-more" ).click(function() {
  $('script... or near').load('page2.html... script code or script
  $('#content').load('page2.html... content
});
</script>

code page2.html:代码页 2.html:

<script class="scriptthis">
some code another
</script>
<div id="content">
<div class="card"></div>
<div class="card"></div>
<div class="card"></div>
<div class="card"></div>
</div>

How to load the code from page 2 on page 1 when the button is clicked?如何在单击按钮时从第 1 页的第 2 页加载代码? Script to script or near - is the main problem.脚本到脚本或接近 - 是主要问题。 and content to the end #content div和内容到最后#content div

Please help with a working solution.请提供有效的解决方案。

$.get() api can do it very easily $.get() api 可以很容易做到

$.get("url_to_page_2", function(htmlContent, status){
  console.log(htmlContent)
});

this can do the job这可以完成工作

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 仅当单击按钮时,如何才能将XHTML页面加载到素面对话框中? - How to load an XHTML page into a dialog in primefaces only when the button is clicked? 如何在页面加载时添加一个计时器,当单击按钮时停止? - How to add a timer on page load that stops when button is clicked? 想要按钮在页面加载时隐藏内容,然后在单击按钮时显示 - Want button to hide content on page load then display when button clicked 页面加载后,按钮仅在第二次单击时才起作用 - After page load, button only works when it is clicked the second time 单击按钮时隐藏已显示页面加载的段落 - hide a paragraph that is already showing page load when button is clicked 使div在页面加载时隐藏,然后在单击按钮时取消隐藏 - Making a div hidden on page load and then unhidden when a button is clicked 单击按钮后,在HTML页面中加载Google Maps - Load Google Maps in HTML page when button is clicked 防止在页面加载时自动单击按钮 - prevent button from being clicked automatically on page load 从PHP代码加载图像,然后在单击时在主页上更改图像 - Load images from PHP code then change an image on the main page when clicked 单击按钮时如何在另一页上显示按钮名称 - How to display button name on another page when button is clicked
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM