0

Would like to copy the current url into a text box and create a prompt before it

I have class assigned to the text box in the form

Is there a way to use something close to the following to make this work?

$('.txtbox').val(window.location.pathname); 

Thanks

1

1 Answer 1

0

This should work:

$('.txtbox').val(window.location.href); 
Sign up to request clarification or add additional context in comments.

2 Comments

Doesn't seem to take - do I need to account for the value="" to make it pre-fill correctly?
I'm not sure what you mean. It is working well for me. Look at this example: jsfiddle.net/jimp/5jRVU Are you possibly trying to execute that script before the <input/> exists in the page?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.