English 中文(简体)
能否把“Query Parse”超文本储存在可变性中?
原标题:Can jQuery Parse HTML Stored in a Variable?

I m利用PHP和Ajax指挥部接收外部网页的全部超文本内容(通过PHP代码<>file_get_contents(的指挥),并将这一超文本转换成单字母变量。 一旦我有一页的超文本内容储存在一个变量中,我能否利用格纳德语与这一变量的内容进行互动,这种方式通常会干扰Query与OM的相互作用? 例如,我试图寻找某些具有特定身份的超文本元素(<div><script>tags)。 谁能建议我如何做到这一点?

最佳回答

如果我正确理解你的话,你就应该能够把变数仅仅通过到支部的职能中来,并相应地开展工作。

的快速例子。

$(myHtml).filter( #someid ).doStuff();
问题回答

Just pass it as a string to the jQuery constructor.

var foo = jQuery( <p><b>asd</b><i>test</i></p> ).
alert(foo.find( i ).text());

你们甚至可以利用土著联合材料这样做。 在这种情形下,使用其内部的超文本财产,如:

document.getElementById( hidden_div_id ).innerHTML = myHTML;

Once the new HTML is added, you can walk through nodes using whatever methods you want.

只是把它注入一个隐蔽的干.,并操纵你们在那里所需要的东西。

var myHTML;//variable with html from php

var $hiddenDIV = $( <div></div> ).hide().appendTo( body ).html(myHTML);
/*Now you can traverse the contents of $hiddenDIV.
 * If you need to get the contents back:
 */ 
var newHTML = $hiddenDIV.html();

是的。 即便无法做到这一点,你也能够提供看不见的四分五裂,然后在座。





相关问题
selected text in iframe

How to get a selected text inside a iframe. I my page i m having a iframe which is editable true. So how can i get the selected text in that iframe.

How to fire event handlers on the link using javascript

I would like to click a link in my page using javascript. I would like to Fire event handlers on the link without navigating. How can this be done? This has to work both in firefox and Internet ...

How to Add script codes before the </body> tag ASP.NET

Heres the problem, In Masterpage, the google analytics code were pasted before the end of body tag. In ASPX page, I need to generate a script (google addItem tracker) using codebehind ClientScript ...

Clipboard access using Javascript - sans Flash?

Is there a reliable way to access the client machine s clipboard using Javascript? I continue to run into permissions issues when attempting to do this. How does Google Docs do this? Do they use ...

javascript debugging question

I have a large javascript which I didn t write but I need to use it and I m slowely going trough it trying to figure out what does it do and how, I m using alert to print out what it does but now I ...

Parsing date like twitter

I ve made a little forum and I want parse the date on newest posts like twitter, you know "posted 40 minutes ago ","posted 1 hour ago"... What s the best way ? Thanx.