Is it possible to have jQuery throw an exception when an element isn't found? -
I am new to jQuery and I would like to simplify the handling of those elements which can not be found, The code shows what I mean:
var class = $ ('select # category'); Now, I can inspect the returned variable to see if it did not get it, but I definitely like the exception being thrown automatically in this case . Is it possible with all jQuery? If not, what is some general phrase to apply such automated error checking on top of jQuery?
To do this, is not sure about any existing functionality, but I think that You put it at the top of the page before using jQuery, but after loading it:
(function () {var _ $ = $; $ = function} {var $ Res = _ $. Apply (0, arguments); if (! $ Res.length & amp; amp; type arguments [0] === 'string') 'No element found:' + Logic [0]; $$ return;} $ = $$ extension (true, $, _ $);}) ();
Comments
Post a Comment