Jump to content

Can you set the href value with JavaScript


Timmie

Recommended Posts

In my HTML code I use images with areas to create links. The areas call JavaScript which changes the source of the image. When the source changes I want to be able to disable and enable certain areas. I've tried doing this by setting "nohref" but the script doesn't recognize the code. Can this be done and if so, what is the proper syntax?

Link to comment
Share on other sites

Give your tag an id, and write something like this:<a id="your_id" href="#" onclick="document.getElementById('your_id').href='new href' "></a>or<img id="your_id" src="img_src" onclick="document.getElementById('your_id').src='new src' " />

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...