我使用PHP和AJAX的命令采取外部网页的整个HTML内容(通过PHP 的file_get_contents()
命令),并通过该HTML到一个javascript变量。有一次,我都存储在一个变量页面的HTML内容,我可以使用jQuery与该变量的内容进行交互,以同样的方式,jQuery的正常与DOM交互?在这个例子中,我试图寻找某些HTML元素(&LT的存在; DIV>
和<脚本>
标签)与特定ID属性。任何人都可以建议我怎么能做到这一点?
I'm using PHP and an ajax command to take the entire HTML contents of an external web page (via the PHP file_get_contents()
command) and passing that HTML into a javascript variable. Once I have the page's HTML contents stored in a variable, can I use jQuery to interact with the contents of that variable, in the same way that jQuery normally interacts with the DOM? In this example, I am trying to search for the existence of certain HTML elements (<div>
and <script>
tags) with specific ID attributes. Can anyone suggest how I can accomplish this?
如果我理解正确的话,你应该能够变量只是传递给jQuery的功能和相应的工作。
If I understand you correctly, you should be able to just pass the variable to the jQuery function and work accordingly.
一个简单的例子与 .filter()
:
$(myHtml).filter('#someid').doStuff();
上一篇:警告:json_en code海量错误()海量、错误、json_en、code
下一篇:使用的是getScript加入回调函数内部生成一个URL我怎么能打开一个新窗口,并避免弹出窗口阻止程序?的是、回调、新窗口、弹出窗口