简体   繁体   English

读取url的Javascript从html页面中获取特定的div标签,并将其放置在另一个页面中。

[英]Javascript that reads in a url takes a certain div tag from the html page and place it in another page.

Hi I'm kind of new to this stuff, but I would like to be able to input a file path or url then the javascript will read a certain div tag then takes it from that html page and place it in another page which I can also input the url or file path. 嗨,我是这个东西的新手,但是我希望能够输入文件路径或url,然后javascript将读取某个div标签,然后从该html页面中获取它,并将其放在另一个页面中,我可以还输入网址或文件路径。 Is this possible? 这可能吗? and can anyone put me on the right track? 谁能把我放在正确的轨道上?

Using Jquery and AJAX you can specify a file path and read a certain div tag's HTML. 使用JqueryAJAX,您可以指定文件路径并读取特定div标签的HTML。 I am not sure that you can place that html into a different page other than the one you are on. 我不确定您是否可以将html放到您所在的页面之外的其他页面中。

$.ajax({
    url: 'ajax/test.html',
    success: function(data) {
        $('.result').html($(data).find("#myDiv").html());
    }
});

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

相关问题 如何修复页面中心 div 标签的 position。 使用 javascript - How to fix the position of the div tag at center of the page. using javascript 将 HTML 页面放入 div - Place HTML page into a div 在另一个页面显示隐藏的div标签 - show hidden div tag from another page 我有一个使用ajax调用在另一个页面的div标签中加载的html页面,我想在加载的页面上触发javascript函数吗? - I have a html page that loaded in div tag in another page using ajax call I want to trigger javascript functions on loaded page? 如何使用javascript将一个html页面上的div内容与另一页面上的div内容更改? - How to change the content of a div on one html page with the contents of a div from another page using javascript? 如何从另一个div标签打开div标签上的页面? - how to open a page on a div tag from another div tag? 从另一个网址页面加载标签内容 - load tag content from another url page 如何在同一位置用另一个 div 标签替换 Div 标签而不使用引导程序重定向到其他页面? - How to replace the Div tag with another div tag on same place without redirecting to other page using bootstrap? 如何从另一个PHP页面引用一个PHP页面中的DIV标记 - How to refer to a DIV tag in a PHP page from another PHP page 只在某个地方制作带有页面的div滚动? - Make a div scroll with page only in a certain place?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM