开发者

appending h2 to image with jquery

hi im trying to add a h2 with the title of an image after each image in my page... this is what ive got so far...

not really sure where im goin wrong

$("img[title]").each(function(){
   this.after开发者_C百科("<h2>" . this.attr(title) "</h2>");
});


I think you're confusing JavaScript with php. Try:

$(this).after("<h2>" + $(this).attr('title') + "</h2>");
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜