views:

498

answers:

4

I have click-able images in my html page that call a javascript function... however nobody is clicking on them as they do not look click-able... how can I make them click-able without using an <a href=""></a> tag around it?

Here is an example of my code...

<div id="bvu11" style="margin: 0px 5px; float: left;">
     <span id="bviu11">
     <img src="/images/icons/favorites_add.png" onclick="favoritesAdd(2,11,'u')">
     </span>
</div>
+3  A: 

Have a look at the css cursor property

<span id="bviu11" style="cursor: pointer;">
cobbal
for goodness sake, don't add it as a style attribute. add a class to the span, then put cursor: pointer in the class. then you can change other style settings for this class in one place and your payload is smaller to boot. .bviu { cursor: pointer } .... <span id="bviu11" class="bviu">
larson4
gotcha... will do that instead in my css, thanks.
Mike Curry
Style attributes are good when it's only applied to one thing. Any more and you should more it to a class.
Isaac Waller
+14  A: 

Using CSS

Add a class to your image (ex: clickable-image) and this in your CSS:

.clickable-image
{
    cursor: pointer;
}
GoodEnough
A: 

Change

<div id="bvu11" style="margin: 0px 5px; float: left;">

to

<div id="bvu11" class="spanLink">

and add

.spanLink {
   margin: 0px 5px; 
   float: left;
   cursor: pointer;
}

to your css.

Jason
+1  A: 

As well as adding the cursor:pointer, perhaps some styling to your images/buttons would also make them appear to be links before the user even has to hover over them. Try a simple border, or dropshadow/glow on the images to give them a more 3D effect, making them look more "clickable"! Also, adding a hover state (a different styling to the image/button) really helps.

Cazmaraline