PSD to HTML conversion PSD to HTML conversion PSD2HTML.com with over 300 professionals takes the designs to HTML and beyond

Subscribe to The Thread

  1. You don’t need the “> 0″, you can simply write:


    if ( $('#myElement').length ) {
    // it exists
    }

    • Eliazer

      No true, since jQuery always returns an object with length 0

    • radiance

      it’s true. If element exists: length > 0, and condition is true.
      If element not exosts: length = 0 and condition is false

  2. Juan Trigueros

    Even easyest and reusable, you can define a function:

    jQuery.fn.exists = function() { return this.length>0; };

    And use it, anywhere, simple like this:

    if ($(‘#myElemento).existe()) { … }

  3. Better,

    if($(element).size()){
    // …
    }

  4. El garch Hicham

    nice tuto :P

Speak, my friend

At this moment, you have an awesome opportunity* to be the person your mother always wanted you to be: kind, helpful, and smart. Do that, and we'll give you a big ol' gold star for the day (literally).

Posting tips:
  • You can use basic HTML
  • When posting code, please turn all
    < characters into &lt;
  • If the code is multi-line, use
    <pre><code></code></pre>
Thank you,
~ The Management ~