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

Popular posts from this blog

html - How to style widget with post count different than without post count -

How to remove text and logo OR add Overflow on Android ActionBar using AppCompat on API 8? -

javascript - storing input from prompt in array and displaying the array -