Solved

click event doesnt work

Posted on 2013-05-17
5
345 Views
Last Modified: 2013-05-22
Hi,

I cant click on my link that is in a div(2nd link). I need this to link to be in a div to swap an image.
How do I enable the click event like the 1st link does?

<a href="home.html"><img  src="images/ic1.png" alt=""/></a>

 
<div id="imgswap"> <a href="home.html"><img id="imgswap" src="images/ic1.png" alt=""/></a></div>  //click event doesnt work?

Open in new window

0
Comment
Question by:jagguy
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
5 Comments
 
LVL 53

Expert Comment

by:Scott Fell, EE MVE
ID: 39176415
You should post your entire page because that code works as is
0
 
LVL 82

Expert Comment

by:leakim971
ID: 39176421
0
 

Accepted Solution

by:
jagguy earned 0 total points
ID: 39176435
OK I found better code to make it work.
I do put it in a list and just swap images over hover.


ul.nav
{
    list-style-type: none;
    padding: 0;
    margin: 0;
    float: left;
    
}

ul.nav a
{
    border: 0px solid #cccccc;
    display: block;
    height: 100px;
    padding-top: 72px;
    width: 100px;
    
}

.nav li#welcome a {
	 background-image:url(images/ic1.png); 
  background-repeat: no-repeat; 
	 
	 }
.nav li#welcome a:hover {
	 background-image:url(images/ic1b.png); 
  background-repeat: no-repeat; 
   }

.nav li#welcome2 a {
	 background-image:url(images/ic1.png); 
  background-repeat: no-repeat; 
	 
	 }
.nav li#welcome2 a:hover {
	 background-image:url(images/ic1b.png); 
  background-repeat: no-repeat; 
   }
 
 
   
#head{
	
}
	
</style>
</head>

<body>


<div id="head">
  <ul class="nav">
    <li id="welcome"><a href="home.html"></a></a></li>
    <li id="welcome2"><a href="home.html"></a></a></li>
  </ul>
</div>

Open in new window

0
 
LVL 9

Expert Comment

by:Sar1973
ID: 39176848
Try to assign another ID to the div: they are identical.
0
 

Author Closing Comment

by:jagguy
ID: 39186895
I found solution (last post)
0

Featured Post

Secure Your WordPress Site: 5 Essential Approaches

WordPress is the web's most popular CMS, but its dominance also makes it a target for attackers. Our eBook will show you how to:

Prevent costly exploits of core and plugin vulnerabilities
Repel automated attacks
Lock down your dashboard, secure your code, and protect your users

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Not sure what the best email signature size is? Are you worried about email signature image size? Follow this best practice guide.
This article demonstrates how to create a simple responsive confirmation dialog with Ok and Cancel buttons using HTML, CSS, jQuery and Promises
In this tutorial viewers will learn how to style a corner ribbon overlay for an image using CSS Create a new class by typing ".Ribbon":  Define the class' "display:" as "inline-block": Define its "position:" as "relative": Define its "overflow:" as …
In this tutorial viewers will learn how to embed custom externally-hosted Google Fonts using the Google Font API in CSS Go to the Google Fonts website at google.com/fonts: Browse or search based on font properties or name to find a suitable font for…

728 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question