[英]Jquery .html and .load
I'm trying to teach myself jQuery and I'm a little stomped with the load() method. 我正在尝试自学jQuery,但对load()方法感到有些不知所措。 I'm working on eBay listings.
我正在处理eBay列表。 Yes, I know includes are not allowed on ebay.
是的,我知道eBay上不允许包含。 However, there is a workaround that has been around for a few years and ebay doesn't seem to be cracking down on it.
但是,有一种解决方法已经存在了几年,而ebay似乎并没有对此进行严厉打击。
var ebayItemID='xxxxxxxxxxxxxx'; // This is eBay code. I cannot edit it.
<h1 id="title"> TO BE REPLACED</h1>
$(document).ready(function(){
var link = "http://www.ebay.com/itm/" + ebayItemID + "?item=" + ebayItemID + &viewitem=&vxp=mtr";
var newTitle = $('#title').load(link + "#itemTitle");
$('#title').html(newTitle);
});
What's the point of this. 这有什么意义。 I want to show the item title on the description, but I want to do so dynamically,
我想在说明中显示项目标题,但我想动态地显示,
You can find more info on the jQuery docs 您可以在jQuery文档中找到更多信息
$('#title').load(link + ' #itemTitle', function() {
alert('Load was performed.');
});
When you use load
will place the returned html into the element(this case #title
). 使用
load
会将返回的html放入元素(本例为#title
)。
So you don't need to call html
after it. 因此,您无需在其后调用
html
。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.