Ccna final exam - java, php, javascript, ios, cshap all in one. This is a collaboratively edited question and answer site for professional and enthusiast programmers. It's 100% free, no registration required.
Monday, February 13, 2012
How to count elements and take attribut of first?
I want to count all img elements and take attribute (alt) of FIRST of it. My try:
$('img').each(function(index) {
/* need count and take forst */
if(index=0){
var objid = $(this).attr('alt');
}
});
var $images = $('img');
ReplyDeletevar imgCount = $images.length;
var altAttrOfFirst = $images.first().attr('alt');
var $img= $('img');
ReplyDeletevar count = $img.length;
var attr = $img.first().attr('alt');