javascript - Putting elements in an array? -
javascript - Putting elements in an array? -
i have question. i'll post html first, know shouldn't utilize tables designing , stuff that. it's learning purposes only.
<table id="placeholder"> <tr> <td><img src="img/1.jpg"/></td> <td><img src="img/2.jpg"/></td> <td><img src="img/3.jpg"/></td> </tr> <tr> <td><img src="img/4.jpg"/></td> <td><img src="img/5.jpg"/></td> <td><img src="img/6.jpg"/></td> </tr> <tr> <td><img src="img/7.jpg"/></td> <td><img src="img/8.jpg"/></td> <td><img src="img/9.jpg"/></td> </tr> <tr> <td><img src="img/10.jpg"/></td> <td><img src="img/11.jpg"/></td> <td><img src="img/12.jpg"/></td> </tr> <tr> <td><img src="img/10.jpg"/></td> <td><img src="img/11.jpg"/></td> <td><img src="img/12.jpg"/></td> </tr> </table> is possible set img's in array? way can fadeout images want. allow want rid of 5th images, can like: images[4].fadeout("slow"); or that. possible this? or there improve way this? i've tried var images = $('td > img'); didn't work (or i'm doing wrong). i'm searching net ways it, haven't found yet help me. might? in advance!
you can select images with
var $images = $('#placeholder img'); if want select specific image, can utilize .eq() [docs]:
$images.eq(4).fadeout(); $images[4] works too, not homecoming jquery object, corresponding dom element. hence cannot phone call fadeout on directly.
without jquery, can images getelementsbytagname [docs]:
var images = document.getelementbyid('placeholder').getelementsbytagname('img'); this gives array (actually nodelist) of dom elements , 1 time again cannot straight phone call jquery method fadeout on them.
javascript jquery arrays
Comments
Post a Comment