Monday, 15 March 2010

html - how do i add an attribute email string into an ahref tag? -



html - how do i add an attribute email string into an ahref tag? -

i have attr

<img class="img_thumb" src="images/cropped9.jpg" author-email="huizhong@hotmail.com">

and

<a class="email" href="mailto:">huizhong@hotmail.com"</a>

i want create email link clickable, read , understand have

<a href="mailto:huizhong@hotmail.com"></a>

but email in img attribute, wonder how can add together href?

thanks

you can utilize .getattribute on img element author-email attribute , set a element's href attribute:

fiddle var image = document.getelementsbyclassname('img_thumb')[0]; var = document.getelementsbyclassname('email')[0]; a.href = "mailto:" + image.getattribute('author-email'); console.log(a)

html css

No comments:

Post a Comment