gpt4 book ai didi

javascript - 如何使用 jQuery 在我自己的页面上显示来自 Url 的内容,

转载 作者:行者123 更新时间:2023-11-30 19:57:41 25 4
gpt4 key购买 nike

$(document).ready(function () {

$("button").click(function () {
$.get("https://talaikis.com/quotes/", function (data, document, quotes) {
$("#test").html(data);
})
})
})

它有点工作,但只有 url 中的按钮显示,其余的不显示。

最佳答案

最好用 jQuery .load() method 在这种情况下:

Load data from the server and place the returned HTML into the matched element.

你的代码应该是这样的:

$("button").click(function () {
$( "#test" ).load("https://talaikis.com/quotes/");
})

注意:

.load()的优点是可以只加载页面中的特定片段,可以查看 the docs 上面写着:

The .load() method, unlike $.get(), allows us to specify a portion of the remote document to be inserted. This is achieved with a special syntax for the url parameter.

关于javascript - 如何使用 jQuery 在我自己的页面上显示来自 Url 的内容,,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53759662/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com