Situation:
I am building a JS tool that lets you edit html templates live in your browser. I’m currently using this code to dump what I type into specific DOM elements:
$('#copyTagline').keyup(function() {
$('#tagline').html($(this).val());
});
So as the user types in the textarea copyTagline it prints in an html object with the id of tagline.
Question:
I want to achieve this with a url so that user can copy and paste in their facebook or twitter url but I can’t insert an html object within my anchor tag. Does anyone know how I could create a variable that is functioning the way I using the snippet above sans html object?
Note: In browsing SO I found some discussions on using docment.write and other various global methods, which make sense, but I’m not sure how I would structure the script to print what ever the user types into the URL string.
Your question is a little unclear. Perhaps you could rephrase the question? Are you trying to rewrite the URI in the location field of the browser? (I ask because of the hashtags you’ve used for this question). In that case, see this post: http://bytes.com/topic/javascript/answers/170365-change-browser-url-without-navigating-away
“but I can’t insert an html object within my anchor tag”
If you’re simply asking how to update the HREF attribute of an anchor tag, try $(“#anchor”).attr(“href”, $(this).val());