Okay, I must be missing something here because this should be extremely simple, yet it doesn\'t work...
I have a form
on my page with an empty act
It does work, you aren't testing it properly. Viewing source will show you what the source looked like when the page was loaded, not after it as modified by jQuery. If you alert()
action value after it is fetched with jQuery, you will see the new value:
alert($("#register").attr("action"));
It's also generally a good idea to make sure that the DOM has loaded before you make any changes, for which you can use ready()
:
$(document).ready(function(){ /* your code */ });
Check out: http://jsfiddle.net/wvYjs/2/