Friday 15 July 2011

javascript - Get Attributes Value for multiple class -



javascript - Get Attributes Value for multiple class -

im javascript beginner. want attribute value on multiple class elements. tried ids, it's not revelent since ids supposed unique.

my html looks :

<a href="#" class="test" onclick="myjavascriptfunc()" data="foobar_1"> <a href="#" class="test" onclick="myjavascriptfunc()" data="foobar_2"> <a href="#" class="test" onclick="myjavascriptfunc()" data="foobar_3">

any help appreciated.

thanks

first close anchor tags

<a href="#" class="test" onclick="return myjavascriptfunc(this);" data="foobar_1">test1</a> <a href="#" class="test" onclick="return myjavascriptfunc(this)" data="foobar_2">test2</a> <a href="#" class="test" onclick="return myjavascriptfunc(this)" data="foobar_3">test3</a>

then utilize javascript function

function myjavascriptfunc(item) { alert(item.getattribute("data")); homecoming false }

and allow me know if works

javascript html class

No comments:

Post a Comment