javascript - Access value of HTML title attribute as variable in onclick function -
i want access value of html title attribute variable onclick function.
this example html elements:
<a title="id:4" onclick="openwin(4)">example</a>
this javascript function:
function openwin(number) { window.open("http://www.some-example.org/some/example/id:"+number) }
this works since have lot of html elements, i'd find way reference title value inside openwin() function instead of writing "openwin(somenumber)". have ideas how this?
any appreciated!
you :
html :
<a title="id:4">example</a>
javascript :
$(function(){ $('a[title]').click(function(){ window.open("http://www.some-example.org/some/example/"+this.title) }); });
Comments
Post a Comment