Note that there are some explanatory texts on larger screens.

plurals
  1. POShow HTML in Console.Log() instead of jQuery selection Object
    primarykey
    data
    text
    <p>I'm to output the real html in Chrome developer console for easier debugging. So I thought of making a chrome extension, which is <a href="https://chrome.google.com/webstore/detail/consolelog-output-real-ht/jnfjicjapkamepnbiplhcjhcjccmegna" rel="nofollow noreferrer">Chrome Extension</a>. </p> <p>I copied the real console.log() to console.nativeLog(); and I added my own custom function to console.log();</p> <p>Here is the code:</p> <pre><code> &lt;div class="myDiv"&gt; &lt;input type="text" id="inp1" title="title1" /&gt; &lt;input type="text" id="inp2" title="title2" /&gt; &lt;input type="text" id="inp3" title="title3" /&gt; &lt;input type="text" id="inp4" /&gt; &lt;input type="text" id="test" value=""&gt; &lt;/div&gt; &lt;input type="button" id="btn1" value="Add" /&gt; &lt;script type="text/javascript"&gt; console.nativeLog = console.log; var arr= new Array(); for(var i=0;i&lt;100;i++){ arr[i] = i+','+i; } var fav = JSON.parse('[{"href":"/EMS-ILS/Modules/Supplier_Profile/Supplier_Profile.aspx?ModID=6&amp;WebPageID=38","text":"Supplier Profile"},{"href":"/EMS-ILS/Modules/Customer_Profile/Customer_Profile.aspx?ModID=6&amp;WebPageID=57","text":"Customer Profile"},{"href":"/EMS-ILS/Modules/Costing_Profile/Costing_Profile.aspx?ModID=6&amp;WebPageID=50","text":"Costing Profile"}]') console.log = function (val){ if(typeof(val)=='string'){ console.nativeLog(val); return; } try{ for(var x=0;x&lt;arguments.length;x++){ var arr = arguments[x]; try{ if(!arr.length) console.nativeLog(arr); else { for(var i=0;i&lt;arr.length;i++) console.nativeLog(arr[i]); } }catch(err1){ console.nativeLog(arr); } } } catch(err2){ console.nativeLog(val); } } $(document).ready(function(){ console.log('-------------'); console.log($('input')); console.log('-------------'); console.log($('#inp1')); console.log('-------------'); console.log($('#badId')); console.log('-------------'); console.log($('input'), $('#bad'), $('input:text'), fav, 0, arr) }); &lt;/script&gt; </code></pre> <p>Everything works fine, but the last one. If the jquery object contains no results, it will still print the context jquery object.</p> <p>This is the output in console.</p> <p><img src="https://i.stack.imgur.com/BdNmB.png" alt="enter image description here"></p> <p>How can prevent that? Any Ideas. Thanks.</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.
 

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