-3
我想要得到的attribute.I的價值屬性的價值,但我不能得到的價值獲取試圖通過</p> <p><code>jQuery('#galleryalbum img').attr('alt'); </code> 搶alt屬性
jQuery(function() {
jQuery(document).ready(function() {
// jQuery('#galleryalbum img').each(function(){
title = jQuery('#galleryalbum img').attr('alt');
console.log(title);
//});
});
});
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js"></script>
<div id="galleryalbum" style="height: 100px; width: auto; position: relative;">
<div id="1" style="float: none; list-style: none; position: absolute; width: 429px; z-index: 0; display: none;">
<img typeof="foaf:Image" src="http://localhost/intranet/sites/default/files/styles/gallery_image/public/Vidhya%20R%20-%20Hi5.jpg?itok=LCNjfrSm" width="700" height="300" alt="" title="Vidhya R - As you look back with pride and a sense of achievement... Here's wishing you many more years of success and joy at Aspire! Happy 5!"
style="width: 100%;">
</div>
</div>
您的代碼似乎工作,但你'ALT =「」'是空的,所以這就是爲什麼它不以'的console.log寫東西( )' –