Il metodo size()
, in origine usato per reperire il numero di elementi presenti in un set jQuery, è stato deprecato. Vediamo i dettagli di questo problema.
La documentazione ufficiale afferma:
The
.size()
method is functionally equivalent to the.length
property; however, the.length
property is preferred because it does not have the overhead of a function call.
Quindi occorre usare length
. Esempio:
alert($('li').length); // 5