You will need to use the text() attribute to do this. so, once you do:
var onclick = $('a').attr('onclick'); You then place it where you want this way: $("a").text(onclick); However, if you have several links on a page it will be better to assign it to an id. Plus, since "onclick" is a javascript handler I'm thinking it may be better to use a different phrase as your variable to avoid confliction. Mike On Sep 15, 9:09 am, sirrocco <xavier...@gmail.com> wrote: > Let's say you have a : > > <a href="#" onclick='DoSomething(this);'>asd</a> > > I want to get the onclick text in a variable - something like > > var onclick = $('a').attr('onclick'); > > The problem is that the onclick variable now is a function and if I > try to execute , this wil be the document instead of the link . > > How can I get only the text, so I can later reattach it to the link ?