using $(this).attr('onclick') seems to convert to function..

using $(this).attr('onclick') seems to convert to function..

Trying to get the contents of a button's onclick value, then use that value after I convert the button to a link. But when i do attr('onclick') it seems to be converting the simple string into an event function. But then when I try to put it back into my link, its all messed up.

Here is the code:


<script type="text/javascript" src="catalog/javascript/ajax/jquery.js"></script>
<script type="text/javascript"><!--
$(document).ready(function(){
   $(":button").each(function(){
      alert($(this).attr('onclick'));
      $(this).replaceWith("<a href=\"#\" onclick=\"" + $(this).attr('onclick') + "\">" + $(this).val() + "</a>");
   });
});
//--></script>
<form action="test.php" id="form1">
    <input type="button" value="clickme" onclick="location='http://localhost/next.php'">
</form>



I'd like just the contents of the onclick without it trying to refunctionalize it. but you can see the contents are simply
location='http://localhost/next.php' but when I alert it, it shows:
function onclick(event) {
location = "http://localhost/next.php";
}
Which would be fine if it worked. But when I re-assign the onclick info to the link's onclick event, I get:

onclick="function onclick(event) {
    location = " http:="" localhost="" next.php&quot;;"


which is all jacked up