我正在尝试获取元素的数据属性,但不知何故它说未定义。这是我的html代码
<div id="imageContainer">
<img data-fullimageid="1" data-title="Cool Stuff" class="backgroundImages" src="images/galvanize/1.jpg" />
<img data-fullimageid="2" data-title="Awesome" class="backgroundImages" src="images/galvanize/1336/dj.jpg" />
<img data-fullimageid="3" data-title="Elite" class="backgroundImages" src="images/galvanize/3.jpg" />
</div>
并使用 Jquery 来提醒它
var firstImageTite = $('.backgroundImages:first-child').data("data-title");
alert(firstImageTite);
它说未定义。请告诉我哪里错了,谢谢。