Note that there are some explanatory texts on larger screens.

plurals
  1. POdiv content is lost after extracting the div from a string by jQuery
    primarykey
    data
    text
    <p><strong>Update:</strong></p> <p>I finally figured out why the content of the #output div is empty. It is because that the content is retrieved from server and it takes time to do so, so by the time the document is loaded the content of this div is still empty.</p> <p>Anyone has idea about extract information from the delayed div content by only using JavaScript or jQuery etc. (client side programming)?</p> <hr> <p>I have a variable which stores a very large string and its content is html. let's call it content.</p> <p>then</p> <p>var html = $.parseHTML(content);</p> <p>after this I want to find this chunk (and extract the values from it)</p> <pre><code>&lt;div id="output" style="float:left;width:150px;margin:30px 0 0 1px;"&gt;&lt;div class="result-title"&gt;Caltex/Woolworths St Kilda&lt;/div&gt;&lt;div class="result-text"&gt;price: 152.9c&lt;br&gt;address: 99 Chapel St &amp;amp; Inkerman St, St Kilda East&lt;/div&gt;&lt;div class="result-title"&gt;BP East Prahran&lt;/div&gt;&lt;div class="result-text"&gt;price: 152.9c&lt;br&gt;address: 549 High St &amp;amp; Chatsworth Rd, Prahran&lt;/div&gt;&lt;div class="result-title"&gt;BP Balaclava&lt;/div&gt;&lt;div class="result-text"&gt;price: 152.9c&lt;br&gt;address: 308 Carlisle St &amp;amp; Blenheim St, Balaclava&lt;/div&gt;&lt;div class="result-title"&gt;7 Eleven St Kilda&lt;/div&gt;&lt;div class="result-text"&gt;price: 153.9c&lt;br&gt;address: 154-158 St Kilda Rd &amp;amp; Alma Rd, St Kilda&lt;/div&gt;&lt;div class="result-title"&gt;BP AA Prahran&lt;/div&gt;&lt;div class="result-text"&gt;price: 153.9c&lt;br&gt;address: 500 Malvern Rd, Prahran&lt;/div&gt;&lt;/div&gt; </code></pre> <p>I tried to loop through it but don't know which attribute should be used to find that chunk.</p> <pre><code> function onS(data) { var html = $.parseHTML(data.responseText); $.each(html, function (i, ele) { if (ele.nodeName == '#div') { alert('found it!!!'); } }); alert("Data Loaded: " + data.responseText); } </code></pre> <p>Please help.</p> <p>****Update:****</p> <p><strong>Code:</strong></p> <pre><code>function onS(data) { // Niclas var nodes = $('#output', data.results[0]); alert("Data Loaded: " + nodes.html()); //Adeneo var node = $(data.results[0]).find('div#output'); alert("Data Loaded: " + node.html()); } </code></pre> <p><strong>The runtime values (please look at innerHTML), it is empty in both ways.</strong></p> <p>(the pic looks like too small, you can press Ctrl + mouse wheel to zoom in/out)</p> <p><img src="https://i.stack.imgur.com/Tgcq1.png" alt="enter image description here"></p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload