Wednesday, 28 February 2018

javascript - The right way parse html to jQuery object

Answer


Answer




I want to parse a html string to jQuery object then find an element by ID.



I tried 3 ways bellow, but only the last works. I don't know why the others not works?



var html = "
";

// Not work, return 0
console.log($(html).find('#main').length);

// Not work, return 0
console.log($($.parseHTML(html)).find('#main').length);
// Works, return 1
console.log($("").html(html).find('#main').length);


Here is the sample:
http://jsfiddle.net/nbyofkam/2/


Answer



It's documented :





When passing in complex HTML, some browsers may not generate a DOM that exactly replicates the HTML source provided. As mentioned, jQuery uses the browser"s .innerHTML property to parse the passed HTML and insert it into the current document. During this process, some browsers filter out certain elements such as , </code>, or <code><head></code> elements. As a result, the elements inserted may not be representative of the original string passed.</p><br/></blockquote><br/><br/><p>As a result, <code>$(html)</code> is reduced to <code>"<div id="main"></div>"</code>. You can verify that by logging <code>$(html)[0].outerHTML</code>.</p><br/><br/><p>So you can't use <code>find</code> without wrapping it, which is what you do.</p><br/> </div> <div style='clear: both;'></div> </div> <div class='post-footer'> <div class='post-footer-line post-footer-line-1'> <span class='post-author vcard'> </span> <span class='post-timestamp'> - <meta content='https://ascodqi.blogspot.com/2018/02/javascript-right-way-parse-html-to.html' itemprop='url'/> <a class='timestamp-link' href='https://ascodqi.blogspot.com/2018/02/javascript-right-way-parse-html-to.html' rel='bookmark' title='permanent link'><abbr class='published' itemprop='datePublished' title='2018-02-28T14:13:00-08:00'>February 28, 2018</abbr></a> </span> <span class='post-comment-link'> </span> <span class='post-icons'> <span class='item-control blog-admin pid-2022133484'> <a href='https://www.blogger.com/post-edit.g?blogID=467282664827998640&postID=3611611736895243905&from=pencil' title='Edit Post'> <img alt='' class='icon-action' height='18' src='https://resources.blogblog.com/img/icon18_edit_allbkg.gif' width='18'/> </a> </span> </span> <div class='post-share-buttons goog-inline-block'> <a class='goog-inline-block share-button sb-email' href='https://www.blogger.com/share-post.g?blogID=467282664827998640&postID=3611611736895243905&target=email' target='_blank' title='Email This'><span class='share-button-link-text'>Email This</span></a><a class='goog-inline-block share-button sb-blog' href='https://www.blogger.com/share-post.g?blogID=467282664827998640&postID=3611611736895243905&target=blog' onclick='window.open(this.href, "_blank", "height=270,width=475"); return false;' target='_blank' title='BlogThis!'><span class='share-button-link-text'>BlogThis!</span></a><a class='goog-inline-block share-button sb-twitter' href='https://www.blogger.com/share-post.g?blogID=467282664827998640&postID=3611611736895243905&target=twitter' target='_blank' title='Share to X'><span class='share-button-link-text'>Share to X</span></a><a class='goog-inline-block share-button sb-facebook' href='https://www.blogger.com/share-post.g?blogID=467282664827998640&postID=3611611736895243905&target=facebook' onclick='window.open(this.href, "_blank", "height=430,width=640"); return false;' target='_blank' title='Share to Facebook'><span class='share-button-link-text'>Share to Facebook</span></a><a class='goog-inline-block share-button sb-pinterest' href='https://www.blogger.com/share-post.g?blogID=467282664827998640&postID=3611611736895243905&target=pinterest' target='_blank' title='Share to Pinterest'><span class='share-button-link-text'>Share to Pinterest</span></a> </div> </div> <div class='post-footer-line post-footer-line-2'> <span class='post-labels'> </span> </div> <div class='post-footer-line post-footer-line-3'> <span class='post-location'> </span> </div> </div> </div> <div class='comments' id='comments'> <a name='comments'></a> <h4>No comments:</h4> <div id='Blog1_comments-block-wrapper'> <dl class='avatar-comment-indent' id='comments-block'> </dl> </div> <p class='comment-footer'> <div class='comment-form'> <a name='comment-form'></a> <h4 id='comment-post-message'>Post a Comment</h4> <p> </p> <a href='https://www.blogger.com/comment/frame/467282664827998640?po=3611611736895243905&hl=en-GB' id='comment-editor-src'></a> <iframe allowtransparency='true' class='blogger-iframe-colorize blogger-comment-from-post' frameborder='0' height='410px' id='comment-editor' name='comment-editor' src='' width='100%'></iframe> <script src='https://www.blogger.com/static/v1/jsbin/2315299244-comment_from_post_iframe.js' type='text/javascript'></script> <script type='text/javascript'> BLOG_CMT_createIframe('https://www.blogger.com/rpc_relay.html'); </script> </div> </p> </div> </div> </div></div> </div> <div class='blog-pager' id='blog-pager'> <span id='blog-pager-newer-link'> <a class='blog-pager-newer-link' href='https://ascodqi.blogspot.com/2018/02/html-css-stroke-on-half-of-web-font.html' id='Blog1_blog-pager-newer-link' title='Newer Post'>Newer Post</a> </span> <span id='blog-pager-older-link'> <a class='blog-pager-older-link' href='https://ascodqi.blogspot.com/2018/02/php-laravel-regex-validation-for-price.html' id='Blog1_blog-pager-older-link' title='Older Post'>Older Post</a> </span> <a class='home-link' href='https://ascodqi.blogspot.com/'>Home</a> </div> <div class='clear'></div> <div class='post-feeds'> <div class='feed-links'> Subscribe to: <a class='feed-link' href='https://ascodqi.blogspot.com/feeds/3611611736895243905/comments/default' target='_blank' type='application/atom+xml'>Post Comments (Atom)</a> </div> </div> </div><div class='widget FeaturedPost' data-version='1' id='FeaturedPost1'> <div class='post-summary'> <h3><a href='https://ascodqi.blogspot.com/2018/05/casting-why-wasn-tobey-maguire-in.html'>casting - Why wasn&#39;t Tobey Maguire in The Amazing Spider-Man? - Movies &amp; TV</a></h3> <p> In the Spider-Man franchise, Tobey Maguire is an outstanding performer as a Spider-Man and also reprised his role in the sequels Spider-Man... </p> </div> <style type='text/css'> .image { width: 100%; } </style> <div class='clear'></div> </div><div class='widget PopularPosts' data-version='1' id='PopularPosts1'> <div class='widget-content popular-posts'> <ul> <li> <div class='item-content'> <div class='item-title'><a href='https://ascodqi.blogspot.com/2017/10/c-qt-project-in-visual-studio-2015.html'>c++ - Qt project in Visual Studio 2015: "unresolved external symbol wWinMain"</a></div> <div class='item-snippet'>The whole error output being: LNK2019 unresolved external symbol wWinMain referenced in function "int __cdecl __scrt_common_main_seh(vo...</div> </div> <div style='clear: both;'></div> </li> <li> <div class='item-content'> <div class='item-title'><a href='https://ascodqi.blogspot.com/2018/05/express-request-header-field-access.html'>express - Request header field Access-Control-Allow-Headers is not allowed by itself in preflight response</a></div> <div class='item-snippet'>I have come across CORS issues multiple times and can usually fix it but I want to really understand by seeing this from a MEAN stack paradi...</div> </div> <div style='clear: both;'></div> </li> <li> <div class='item-content'> <div class='item-title'><a href='https://ascodqi.blogspot.com/2018/05/javascript-load-image-into-offscreen.html'>Javascript load Image into Offscreen Canvas, perform webp conversion</a></div> <div class='item-snippet'>I recently used canvas to conert images to webp, using : const dataUrl = canvas.toDataURL('image/webp'); But this takes a lots of ti...</div> </div> <div style='clear: both;'></div> </li> </ul> <div class='clear'></div> </div> </div></div> </div> </div> <div class='column-left-outer'> <div class='column-left-inner'> <aside> </aside> </div> </div> <div class='column-right-outer'> <div class='column-right-inner'> <aside> <div class='sidebar section' id='sidebar-right-1'><div class='widget BlogSearch' data-version='1' id='BlogSearch1'> <h2 class='title'>Search This Blog</h2> <div class='widget-content'> <div id='BlogSearch1_form'> <form action='https://ascodqi.blogspot.com/search' class='gsc-search-box' target='_top'> <table cellpadding='0' cellspacing='0' class='gsc-search-box'> <tbody> <tr> <td class='gsc-input'> <input autocomplete='off' class='gsc-input' name='q' size='10' title='search' type='text' value=''/> </td> <td class='gsc-search-button'> <input class='gsc-search-button' title='search' type='submit' value='Search'/> </td> </tr> </tbody> </table> </form> </div> </div> <div class='clear'></div> </div><div class='widget BlogArchive' data-version='1' id='BlogArchive1'> <h2>Blog Archive</h2> <div class='widget-content'> <div id='ArchiveList'> <div id='BlogArchive1_ArchiveList'> <ul class='hierarchy'> <li class='archivedate expanded'> <a class='toggle' href='javascript:void(0)'> <span class='zippy toggle-open'> ▼  </span> </a> <a class='post-count-link' href='https://ascodqi.blogspot.com/2018/'> 2018 </a> <span class='post-count' dir='ltr'>(1601)</span> <ul class='hierarchy'> <li class='archivedate collapsed'> <a class='toggle' href='javascript:void(0)'> <span class='zippy'> ►  </span> </a> <a class='post-count-link' href='https://ascodqi.blogspot.com/2018/05/'> May 2018 </a> <span class='post-count' dir='ltr'>(263)</span> </li> </ul> <ul class='hierarchy'> <li class='archivedate collapsed'> <a class='toggle' href='javascript:void(0)'> <span class='zippy'> ►  </span> </a> <a class='post-count-link' href='https://ascodqi.blogspot.com/2018/04/'> April 2018 </a> <span class='post-count' dir='ltr'>(419)</span> </li> </ul> <ul class='hierarchy'> <li class='archivedate collapsed'> <a class='toggle' href='javascript:void(0)'> <span class='zippy'> ►  </span> </a> <a class='post-count-link' href='https://ascodqi.blogspot.com/2018/03/'> March 2018 </a> <span class='post-count' dir='ltr'>(430)</span> </li> </ul> <ul class='hierarchy'> <li class='archivedate expanded'> <a class='toggle' href='javascript:void(0)'> <span class='zippy toggle-open'> ▼  </span> </a> <a class='post-count-link' href='https://ascodqi.blogspot.com/2018/02/'> February 2018 </a> <span class='post-count' dir='ltr'>(351)</span> <ul class='posts'> <li><a href='https://ascodqi.blogspot.com/2018/02/php-laravel-regex-validation-for-price_28.html'>php - Laravel regex validation for price OR empty</a></li> <li><a href='https://ascodqi.blogspot.com/2018/02/javascript-template-literal-trapped-in.html'>javascript - Template literal trapped in a string ...</a></li> <li><a href='https://ascodqi.blogspot.com/2018/02/c-trying-to-use-class-as-property-for.html'>c# - Trying to use a class as a property for other...</a></li> <li><a href='https://ascodqi.blogspot.com/2018/02/html-css-stroke-on-half-of-web-font.html'>html - CSS stroke on half of web font</a></li> <li><a href='https://ascodqi.blogspot.com/2018/02/javascript-right-way-parse-html-to.html'>javascript - The right way parse html to jQuery ob...</a></li> <li><a href='https://ascodqi.blogspot.com/2018/02/php-laravel-regex-validation-for-price.html'>php - Laravel regex validation for price OR empty</a></li> <li><a href='https://ascodqi.blogspot.com/2018/02/the-dark-knight-rises-why-did-nolan.html'>the dark knight rises - Why did Nolan want to end ...</a></li> <li><a href='https://ascodqi.blogspot.com/2018/02/javascript-what-is-difference-between.html'>javascript - What is the difference between substr...</a></li> <li><a href='https://ascodqi.blogspot.com/2018/02/c-what-difference-between-passing.html'>c++ - What's the difference between passing argume...</a></li> <li><a href='https://ascodqi.blogspot.com/2018/02/thread-exceptions-android-caused-by.html'>thread exceptions - Android : Caused by: android.o...</a></li> <li><a href='https://ascodqi.blogspot.com/2018/02/why-is-it-bad-style-to-rescue-exception.html'>Why is it bad style to `rescue Exception => e` in ...</a></li> <li><a href='https://ascodqi.blogspot.com/2018/02/javascript-index-loop-does-not-change.html'>javascript - Index loop does not change</a></li> <li><a href='https://ascodqi.blogspot.com/2018/02/php-parse-error-syntax-error-unexpected_28.html'>php - Parse error: syntax error, unexpected 'endif...</a></li> <li><a href='https://ascodqi.blogspot.com/2018/02/regex-in-vba-excel.html'>Regex in Vba excel</a></li> <li><a href='https://ascodqi.blogspot.com/2018/02/compiler-construction-compiling-cc-files.html'>compiler construction - Compiling .cc files?</a></li> <li><a href='https://ascodqi.blogspot.com/2018/02/what-is-androidems-attribute-in-edit.html'>What is android:ems attribute in Edit Text?</a></li> <li><a href='https://ascodqi.blogspot.com/2018/02/redirect-from-html-page.html'>Redirect from an HTML page</a></li> <li><a href='https://ascodqi.blogspot.com/2018/02/optimization-how-to-index-1-million.html'>optimization - How to index 1 million rows mySQL t...</a></li> <li><a href='https://ascodqi.blogspot.com/2018/02/php-vs-as-operator.html'>php - 'AND' vs '&&' as operator</a></li> <li><a href='https://ascodqi.blogspot.com/2018/02/php-when-should-i-use-memcache-instead.html'>php - When should I use Memcache instead of Memcac...</a></li> <li><a href='https://ascodqi.blogspot.com/2018/02/static-declaration-and-definition-of.html'>static - Declaration and Definition of variables in c</a></li> <li><a href='https://ascodqi.blogspot.com/2018/02/nodejs-javascript-dependency-management.html'>node.js - JavaScript dependency management: npm vs...</a></li> <li><a href='https://ascodqi.blogspot.com/2018/02/performance-using-lttng-to-sample-perf.html'>performance - Using LTTng to sample perf counters ...</a></li> <li><a href='https://ascodqi.blogspot.com/2018/02/php-mysql-error-in-sql-syntax-check.html'>php - MySQL Error in SQL syntax; check the manual ...</a></li> <li><a href='https://ascodqi.blogspot.com/2018/02/php-function-not-sending-email_27.html'>PHP 'mail()' Function Not Sending Email</a></li> <li><a href='https://ascodqi.blogspot.com/2018/02/javascript-html-unable-to-execute-code.html'>javascript - HTML : Unable to execute code in bloc...</a></li> <li><a href='https://ascodqi.blogspot.com/2018/02/javascript-how-do-i-export-array-with.html'>javascript - How do I export an array with module....</a></li> <li><a href='https://ascodqi.blogspot.com/2018/02/vba-i-am-getting-error-can-find-project.html'>vba - I am getting 'Compile error: Can't find proj...</a></li> <li><a href='https://ascodqi.blogspot.com/2018/02/css-flexbox-align-items-horizontally.html'>css - Flexbox align items horizontally</a></li> <li><a href='https://ascodqi.blogspot.com/2018/02/advanced-javascript-why-is-this.html'>Advanced JavaScript: Why is this function wrapped ...</a></li> <li><a href='https://ascodqi.blogspot.com/2018/02/plot-explanation-what-career-was-troy.html'>plot explanation - What career was Troy planning o...</a></li> <li><a href='https://ascodqi.blogspot.com/2018/02/c-how-do-i-make-unit-test-to-test_26.html'>c# - How do I make a unit test to test a method th...</a></li> <li><a href='https://ascodqi.blogspot.com/2018/02/android-studio-082-gradle-project-sync.html'>Android Studio 0.8.2 - Gradle project sync failed</a></li> <li><a href='https://ascodqi.blogspot.com/2018/02/regex-regular-expressions-in-excel-vba.html'>regex - Regular Expressions in Excel VBA</a></li> <li><a href='https://ascodqi.blogspot.com/2018/02/mysql-having-issue-backing-up-my.html'>mysql - Having An Issue Backing Up MY Database Fro...</a></li> <li><a href='https://ascodqi.blogspot.com/2018/02/html-php-mail-not-working-properly.html'>html - PHP Mail not working properly</a></li> <li><a href='https://ascodqi.blogspot.com/2018/02/how-i-write-function-in-python-that.html'>How I write a function in python that determines w...</a></li> <li><a href='https://ascodqi.blogspot.com/2018/02/html-marathi-language-not-shown.html'>html - marathi language not shown properly in browser</a></li> <li><a href='https://ascodqi.blogspot.com/2018/02/c-how-do-structs-behave-in-terms-of.html'>c - How do structs behave in terms of visibility t...</a></li> <li><a href='https://ascodqi.blogspot.com/2018/02/c-how-do-i-make-unit-test-to-test_25.html'>c# - How do I make a unit test to test a method th...</a></li> <li><a href='https://ascodqi.blogspot.com/2018/02/ruby-nokogiri-css-html-parsing.html'>RUBY Nokogiri CSS HTML Parsing</a></li> <li><a href='https://ascodqi.blogspot.com/2018/02/reading-from-json-file-c.html'>Reading from JSON File C#</a></li> <li><a href='https://ascodqi.blogspot.com/2018/02/plot-explanation-how-does-blake-know.html'>plot explanation - How does Blake know that Bruce ...</a></li> <li><a href='https://ascodqi.blogspot.com/2018/02/java-what-is-dependency-injection.html'>java - What is Dependency Injection?</a></li> <li><a href='https://ascodqi.blogspot.com/2018/02/javascript-php-form-emailing-but-post.html'>javascript - Php form emailing but $_POST['email']...</a></li> <li><a href='https://ascodqi.blogspot.com/2018/02/how-to-store-dynamic-table-value-using.html'>How to Store dynamic table value using SharedPrefe...</a></li> <li><a href='https://ascodqi.blogspot.com/2018/02/data-structures-array-versus-linked-list.html'>data structures - Array versus linked-list</a></li> <li><a href='https://ascodqi.blogspot.com/2018/02/html-detect-click-on-via-php_25.html'>html - Detect click on via PHP</a></li> <li><a href='https://ascodqi.blogspot.com/2018/02/plot-explanation-are-teletubbies-cyborgs.html'>plot explanation - Are the teletubbies cyborgs?</a></li> <li><a href='https://ascodqi.blogspot.com/2018/02/javascript-how-to-simplify-this.html'>javascript - how to simplify this statement using ...</a></li> <li><a href='https://ascodqi.blogspot.com/2018/02/php-cannot-modify-header-information_24.html'>php - "Warning: Cannot modify header information -...</a></li> <li><a href='https://ascodqi.blogspot.com/2018/02/javascript-nodejs-wait-for-all-files.html'>javascript - Node.js wait for all files read in th...</a></li> <li><a href='https://ascodqi.blogspot.com/2018/02/regex-regular-expression-to-match-line.html'>regex - Regular expression to match a line that do...</a></li> <li><a href='https://ascodqi.blogspot.com/2018/02/javascript-lazy-loading-of-components.html'>javascript - lazy loading of components in angular...</a></li> <li><a href='https://ascodqi.blogspot.com/2018/02/c-object-reference-not-set-to-object.html'>c# - Object Reference not set to an object (callin...</a></li> <li><a href='https://ascodqi.blogspot.com/2018/02/email-outlook-2010-vba-msgbox-if-more.html'>email - Outlook 2010 - VBA MsgBox if more then 10 ...</a></li> <li><a href='https://ascodqi.blogspot.com/2018/02/c-when-to-use-references-vs-pointers.html'>c++ - When to use references vs. pointers</a></li> <li><a href='https://ascodqi.blogspot.com/2018/02/c-memcpy-moving-128-bit-in-linux.html'>c - memcpy moving 128 bit in linux</a></li> <li><a href='https://ascodqi.blogspot.com/2018/02/oop-what-are-metaclasses-in-python.html'>oop - What are metaclasses in Python?</a></li> <li><a href='https://ascodqi.blogspot.com/2018/02/mysql-case-sensitivity-table-name-on.html'>MySQL case sensitivity table name on MacOS with ca...</a></li> <li><a href='https://ascodqi.blogspot.com/2018/02/php-error-500-after-renaming-my-laravel.html'>php - Error 500 after renaming my Laravel Project ...</a></li> <li><a href='https://ascodqi.blogspot.com/2018/02/plot-explanation-why-is-it-impossible.html'>plot explanation - Why is it impossible for women ...</a></li> <li><a href='https://ascodqi.blogspot.com/2018/02/java-how-to-allow-users-to-check-for.html'>java - How to allow users to check for the latest ...</a></li> <li><a href='https://ascodqi.blogspot.com/2018/02/credits-why-was-movie-wicker-man.html'>credits - Why was the movie The Wicker Man dedicat...</a></li> <li><a href='https://ascodqi.blogspot.com/2018/02/c-return-stdstring-as-const-reference.html'>c++ - Return std::string as const reference</a></li> <li><a href='https://ascodqi.blogspot.com/2018/02/css-is-there-sibling-selector.html'>css - Is there a "previous sibling" selector?</a></li> <li><a href='https://ascodqi.blogspot.com/2018/02/deserializing-json-data-to-c-using.html'>Deserializing JSON data to C# using JSON.NET</a></li> <li><a href='https://ascodqi.blogspot.com/2018/02/java-eclipse-enable-multidex.html'>java - Eclipse enable multidex</a></li> <li><a href='https://ascodqi.blogspot.com/2018/02/reference-what-does-this-regex-mean.html'>Reference - What does this regex mean?</a></li> <li><a href='https://ascodqi.blogspot.com/2018/02/java-turn-annual-interest-into-monthly.html'>java - Turn annual interest into monthly</a></li> <li><a href='https://ascodqi.blogspot.com/2018/02/class-does-python-have-private.html'>class - Does Python have “private” variables in cl...</a></li> <li><a href='https://ascodqi.blogspot.com/2018/02/javascript-how-do-i-check-if-element-is.html'>javascript - How do I check if an element is hidde...</a></li> <li><a href='https://ascodqi.blogspot.com/2018/02/if-statement-type-juggling-and-strict.html'>if statement - Type-juggling and (strict) greater/...</a></li> <li><a href='https://ascodqi.blogspot.com/2018/02/c-address-of-start-block-storage.html'>c++ - Address of start block storage</a></li> <li><a href='https://ascodqi.blogspot.com/2018/02/how-to-start-object-orient-programming.html'>How to start object orient programming in C++?</a></li> <li><a href='https://ascodqi.blogspot.com/2018/02/make-javascript-array-from-url.html'>Make a JavaScript array from URL</a></li> <li><a href='https://ascodqi.blogspot.com/2018/02/performance-why-is-there-significant.html'>performance - Why is there a significant differenc...</a></li> <li><a href='https://ascodqi.blogspot.com/2018/02/reactjs-is-it-more-performant-to-pass.html'>reactjs - Is it More Performant to Pass Props From...</a></li> <li><a href='https://ascodqi.blogspot.com/2018/02/python-import-module-from-relative-path.html'>python - Import a module from a relative path</a></li> <li><a href='https://ascodqi.blogspot.com/2018/02/javascript-cannot-set-property.html'>javascript - Cannot set property InnerHTML of null</a></li> <li><a href='https://ascodqi.blogspot.com/2018/02/are-table-names-in-mysql-case-sensitive.html'>Are table names in MySQL case sensitive?</a></li> <li><a href='https://ascodqi.blogspot.com/2018/02/python-image-processing-algorithm.html'>python - Image Processing: Algorithm Improvement f...</a></li> <li><a href='https://ascodqi.blogspot.com/2018/02/html-how-can-i-change-placeholder-text.html'>html - How can i change the placeholder text color...</a></li> <li><a href='https://ascodqi.blogspot.com/2018/02/sql-what-is-advantage-of-inner-join.html'>sql - what is the advantage of inner join tables</a></li> <li><a href='https://ascodqi.blogspot.com/2018/02/c-how-can-adding-code-to-loop-make-it.html'>c++ - How can adding code to a loop make it faster?</a></li> <li><a href='https://ascodqi.blogspot.com/2018/02/echo-newline-in-bash-prints-literal-n.html'>Echo newline in Bash prints literal n</a></li> <li><a href='https://ascodqi.blogspot.com/2018/02/multithreading-atomic-pointers-in-c-and.html'>multithreading - Atomic pointers in c++ and passin...</a></li> <li><a href='https://ascodqi.blogspot.com/2018/02/java-android-multidex-install.html'>java - Android - MultiDex Install</a></li> <li><a href='https://ascodqi.blogspot.com/2018/02/json-convert-javautildate-to.html'>json - Convert java.util.Date to java.sql.Date wit...</a></li> <li><a href='https://ascodqi.blogspot.com/2018/02/php-cannot-modify-header-information.html'>php - Cannot modify header information error recieved</a></li> <li><a href='https://ascodqi.blogspot.com/2018/02/php-laravel-5-redirect-to-https.html'>php - Laravel 5 - redirect to HTTPS</a></li> <li><a href='https://ascodqi.blogspot.com/2018/02/c-unit-test-mock.html'>C# - Unit test, Mock?</a></li> <li><a href='https://ascodqi.blogspot.com/2018/02/javascript-how-to-avoid-cascading.html'>javascript - How to avoid cascading promises and c...</a></li> <li><a href='https://ascodqi.blogspot.com/2018/02/r-full-outer-join-of-multiple.html'>r - Full outer join of multiple dataframes stored ...</a></li> <li><a href='https://ascodqi.blogspot.com/2018/02/php-codeigniter-auto-loading.html'>php - CodeIgniter Auto Loading form_validation cau...</a></li> <li><a href='https://ascodqi.blogspot.com/2018/02/x86-assembly-rep-mov-mechanism.html'>x86 - Assembly: REP MOV mechanism</a></li> <li><a href='https://ascodqi.blogspot.com/2018/02/sort-array-of-objects-by-specific-key.html'>Sort Array of Objects by specific key value | Java...</a></li> <li><a href='https://ascodqi.blogspot.com/2018/02/java-unsupported-majorminor-version-520.html'>java - Unsupported major.minor version 52.0</a></li> <li><a href='https://ascodqi.blogspot.com/2018/02/sql-server-why-execute-stored.html'>sql server - Why execute stored procedures is fast...</a></li> <li><a href='https://ascodqi.blogspot.com/2018/02/oop-what-techniques-can-be-used-to.html'>oop - What techniques can be used to define a clas...</a></li> </ul> </li> </ul> <ul class='hierarchy'> <li class='archivedate collapsed'> <a class='toggle' href='javascript:void(0)'> <span class='zippy'> ►  </span> </a> <a class='post-count-link' href='https://ascodqi.blogspot.com/2018/01/'> January 2018 </a> <span class='post-count' dir='ltr'>(138)</span> </li> </ul> </li> </ul> <ul class='hierarchy'> <li class='archivedate collapsed'> <a class='toggle' href='javascript:void(0)'> <span class='zippy'> ►  </span> </a> <a class='post-count-link' href='https://ascodqi.blogspot.com/2017/'> 2017 </a> <span class='post-count' dir='ltr'>(1575)</span> <ul class='hierarchy'> <li class='archivedate collapsed'> <a class='toggle' href='javascript:void(0)'> <span class='zippy'> ►  </span> </a> <a class='post-count-link' href='https://ascodqi.blogspot.com/2017/10/'> October 2017 </a> <span class='post-count' dir='ltr'>(102)</span> </li> </ul> <ul class='hierarchy'> <li class='archivedate collapsed'> <a class='toggle' href='javascript:void(0)'> <span class='zippy'> ►  </span> </a> <a class='post-count-link' href='https://ascodqi.blogspot.com/2017/09/'> September 2017 </a> <span class='post-count' dir='ltr'>(430)</span> </li> </ul> <ul class='hierarchy'> <li class='archivedate collapsed'> <a class='toggle' href='javascript:void(0)'> <span class='zippy'> ►  </span> </a> <a class='post-count-link' href='https://ascodqi.blogspot.com/2017/08/'> August 2017 </a> <span class='post-count' dir='ltr'>(444)</span> </li> </ul> <ul class='hierarchy'> <li class='archivedate collapsed'> <a class='toggle' href='javascript:void(0)'> <span class='zippy'> ►  </span> </a> <a class='post-count-link' href='https://ascodqi.blogspot.com/2017/07/'> July 2017 </a> <span class='post-count' dir='ltr'>(425)</span> </li> </ul> <ul class='hierarchy'> <li class='archivedate collapsed'> <a class='toggle' href='javascript:void(0)'> <span class='zippy'> ►  </span> </a> <a class='post-count-link' href='https://ascodqi.blogspot.com/2017/06/'> June 2017 </a> <span class='post-count' dir='ltr'>(174)</span> </li> </ul> </li> </ul> </div> </div> <div class='clear'></div> </div> </div></div> <table border='0' cellpadding='0' cellspacing='0' class='section-columns columns-2'> <tbody> <tr> <td class='first columns-cell'> <div class='sidebar no-items section' id='sidebar-right-2-1'></div> </td> <td class='columns-cell'> <div class='sidebar no-items section' id='sidebar-right-2-2'></div> </td> </tr> </tbody> </table> <div class='sidebar no-items section' id='sidebar-right-3'></div> </aside> </div> </div> </div> <div style='clear: both'></div> <!-- columns --> </div> <!-- main --> </div> </div> <div class='main-cap-bottom cap-bottom'> <div class='cap-left'></div> <div class='cap-right'></div> </div> </div> <footer> <div class='footer-outer'> <div class='footer-cap-top cap-top'> <div class='cap-left'></div> <div class='cap-right'></div> </div> <div class='fauxborder-left footer-fauxborder-left'> <div class='fauxborder-right footer-fauxborder-right'></div> <div class='region-inner footer-inner'> <div class='foot no-items section' id='footer-1'></div> <table border='0' cellpadding='0' cellspacing='0' class='section-columns columns-2'> <tbody> <tr> <td class='first columns-cell'> <div class='foot no-items section' id='footer-2-1'></div> </td> <td class='columns-cell'> <div class='foot no-items section' id='footer-2-2'></div> </td> </tr> </tbody> </table> <!-- outside of the include in order to lock Attribution widget --> <div class='foot section' id='footer-3' name='Footer'><div class='widget Attribution' data-version='1' id='Attribution1'> <div class='widget-content' style='text-align: center;'> Theme images by <a href='http://www.istockphoto.com/file_closeup.php?id=9505737&platform=blogger' target='_blank'>Ollustrator</a>. Powered by <a href='https://www.blogger.com' target='_blank'>Blogger</a>. </div> <div class='clear'></div> </div></div> </div> </div> <div class='footer-cap-bottom cap-bottom'> <div class='cap-left'></div> <div class='cap-right'></div> </div> </div> </footer> <!-- content --> </div> </div> <div class='content-cap-bottom cap-bottom'> <div class='cap-left'></div> <div class='cap-right'></div> </div> </div> </div> <script type='text/javascript'> window.setTimeout(function() { document.body.className = document.body.className.replace('loading', ''); }, 10); </script> <script type="text/javascript" src="https://www.blogger.com/static/v1/widgets/984859869-widgets.js"></script> <script type='text/javascript'> window['__wavt'] = 'AOuZoY6btgsHzzipc85bQSUAGTthh7B6SA:1731565543067';_WidgetManager._Init('//www.blogger.com/rearrange?blogID\x3d467282664827998640','//ascodqi.blogspot.com/2018/02/javascript-right-way-parse-html-to.html','467282664827998640'); _WidgetManager._SetDataContext([{'name': 'blog', 'data': {'blogId': '467282664827998640', 'title': 'Blog', 'url': 'https://ascodqi.blogspot.com/2018/02/javascript-right-way-parse-html-to.html', 'canonicalUrl': 'https://ascodqi.blogspot.com/2018/02/javascript-right-way-parse-html-to.html', 'homepageUrl': 'https://ascodqi.blogspot.com/', 'searchUrl': 'https://ascodqi.blogspot.com/search', 'canonicalHomepageUrl': 'https://ascodqi.blogspot.com/', 'blogspotFaviconUrl': 'https://ascodqi.blogspot.com/favicon.ico', 'bloggerUrl': 'https://www.blogger.com', 'hasCustomDomain': false, 'httpsEnabled': true, 'enabledCommentProfileImages': true, 'gPlusViewType': 'FILTERED_POSTMOD', 'adultContent': false, 'analyticsAccountNumber': '', 'encoding': 'UTF-8', 'locale': 'en-GB', 'localeUnderscoreDelimited': 'en_gb', 'languageDirection': 'ltr', 'isPrivate': false, 'isMobile': false, 'isMobileRequest': false, 'mobileClass': '', 'isPrivateBlog': false, 'isDynamicViewsAvailable': true, 'feedLinks': '\x3clink rel\x3d\x22alternate\x22 type\x3d\x22application/atom+xml\x22 title\x3d\x22Blog - Atom\x22 href\x3d\x22https://ascodqi.blogspot.com/feeds/posts/default\x22 /\x3e\n\x3clink rel\x3d\x22alternate\x22 type\x3d\x22application/rss+xml\x22 title\x3d\x22Blog - RSS\x22 href\x3d\x22https://ascodqi.blogspot.com/feeds/posts/default?alt\x3drss\x22 /\x3e\n\x3clink rel\x3d\x22service.post\x22 type\x3d\x22application/atom+xml\x22 title\x3d\x22Blog - Atom\x22 href\x3d\x22https://www.blogger.com/feeds/467282664827998640/posts/default\x22 /\x3e\n\n\x3clink rel\x3d\x22alternate\x22 type\x3d\x22application/atom+xml\x22 title\x3d\x22Blog - Atom\x22 href\x3d\x22https://ascodqi.blogspot.com/feeds/3611611736895243905/comments/default\x22 /\x3e\n', 'meTag': '', 'adsenseHostId': 'ca-host-pub-1556223355139109', 'adsenseHasAds': true, 'adsenseAutoAds': false, 'boqCommentIframeForm': true, 'loginRedirectParam': '', 'view': '', 'dynamicViewsCommentsSrc': '//www.blogblog.com/dynamicviews/4224c15c4e7c9321/js/comments.js', 'dynamicViewsScriptSrc': '//www.blogblog.com/dynamicviews/a4858bff8adcc0f1', 'plusOneApiSrc': 'https://apis.google.com/js/platform.js', 'disableGComments': true, 'interstitialAccepted': false, 'sharing': {'platforms': [{'name': 'Get link', 'key': 'link', 'shareMessage': 'Get link', 'target': ''}, {'name': 'Facebook', 'key': 'facebook', 'shareMessage': 'Share to Facebook', 'target': 'facebook'}, {'name': 'BlogThis!', 'key': 'blogThis', 'shareMessage': 'BlogThis!', 'target': 'blog'}, {'name': 'X', 'key': 'twitter', 'shareMessage': 'Share to X', 'target': 'twitter'}, {'name': 'Pinterest', 'key': 'pinterest', 'shareMessage': 'Share to Pinterest', 'target': 'pinterest'}, {'name': 'Email', 'key': 'email', 'shareMessage': 'Email', 'target': 'email'}], 'disableGooglePlus': true, 'googlePlusShareButtonWidth': 0, 'googlePlusBootstrap': '\x3cscript type\x3d\x22text/javascript\x22\x3ewindow.___gcfg \x3d {\x27lang\x27: \x27en_GB\x27};\x3c/script\x3e'}, 'hasCustomJumpLinkMessage': false, 'jumpLinkMessage': 'Read more', 'pageType': 'item', 'postId': '3611611736895243905', 'pageName': 'javascript - The right way parse html to jQuery object', 'pageTitle': 'Blog: javascript - The right way parse html to jQuery object'}}, {'name': 'features', 'data': {}}, {'name': 'messages', 'data': {'edit': 'Edit', 'linkCopiedToClipboard': 'Link copied to clipboard', 'ok': 'Ok', 'postLink': 'Post link'}}, {'name': 'template', 'data': {'name': 'custom', 'localizedName': 'Custom', 'isResponsive': false, 'isAlternateRendering': false, 'isCustom': true}}, {'name': 'view', 'data': {'classic': {'name': 'classic', 'url': '?view\x3dclassic'}, 'flipcard': {'name': 'flipcard', 'url': '?view\x3dflipcard'}, 'magazine': {'name': 'magazine', 'url': '?view\x3dmagazine'}, 'mosaic': {'name': 'mosaic', 'url': '?view\x3dmosaic'}, 'sidebar': {'name': 'sidebar', 'url': '?view\x3dsidebar'}, 'snapshot': {'name': 'snapshot', 'url': '?view\x3dsnapshot'}, 'timeslide': {'name': 'timeslide', 'url': '?view\x3dtimeslide'}, 'isMobile': false, 'title': 'javascript - The right way parse html to jQuery object', 'description': ' Answer Answer I want to parse a html string to jQuery object then find an element by ID. I tried 3 ways bellow, but only the last works....', 'url': 'https://ascodqi.blogspot.com/2018/02/javascript-right-way-parse-html-to.html', 'type': 'item', 'isSingleItem': true, 'isMultipleItems': false, 'isError': false, 'isPage': false, 'isPost': true, 'isHomepage': false, 'isArchive': false, 'isLabelSearch': false, 'postId': 3611611736895243905}}]); _WidgetManager._RegisterWidget('_NavbarView', new _WidgetInfo('Navbar1', 'navbar', document.getElementById('Navbar1'), {}, 'displayModeFull')); _WidgetManager._RegisterWidget('_HeaderView', new _WidgetInfo('Header1', 'header', document.getElementById('Header1'), {}, 'displayModeFull')); _WidgetManager._RegisterWidget('_BlogView', new _WidgetInfo('Blog1', 'main', document.getElementById('Blog1'), {'cmtInteractionsEnabled': false, 'lightboxEnabled': true, 'lightboxModuleUrl': 'https://www.blogger.com/static/v1/jsbin/1210611890-lbx__en_gb.js', 'lightboxCssUrl': 'https://www.blogger.com/static/v1/v-css/1964470060-lightbox_bundle.css'}, 'displayModeFull')); _WidgetManager._RegisterWidget('_FeaturedPostView', new _WidgetInfo('FeaturedPost1', 'main', document.getElementById('FeaturedPost1'), {}, 'displayModeFull')); _WidgetManager._RegisterWidget('_PopularPostsView', new _WidgetInfo('PopularPosts1', 'main', document.getElementById('PopularPosts1'), {}, 'displayModeFull')); _WidgetManager._RegisterWidget('_BlogSearchView', new _WidgetInfo('BlogSearch1', 'sidebar-right-1', document.getElementById('BlogSearch1'), {}, 'displayModeFull')); _WidgetManager._RegisterWidget('_BlogArchiveView', new _WidgetInfo('BlogArchive1', 'sidebar-right-1', document.getElementById('BlogArchive1'), {'languageDirection': 'ltr', 'loadingMessage': 'Loading\x26hellip;'}, 'displayModeFull')); _WidgetManager._RegisterWidget('_AttributionView', new _WidgetInfo('Attribution1', 'footer-3', document.getElementById('Attribution1'), {}, 'displayModeFull')); </script> </body> </html>