开发者

appending h2 to image with jquery

开发者 https://www.devze.com 2022-12-08 09:58 出处:网络
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...

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

精彩评论

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

关注公众号