Jump to content

css hover functon into javascript onclick function help


Minimeallolla

Recommended Posts


.image-hover
{
border:0;
position:center;
width:auto;
height:auto;
z-index:10000;  
}

a.image img
{
width:75x;
height:75px;
}

a.image:hover img
{
border:0;
position:center;
width:auto;
height:auto;
z-index:10000;  
}

 

Is there a way of turning those hover functions into a javascript onclick function?

 

Link to comment
Share on other sites

I'm not sure I understand the question.  Stylesheets do not support procedural code.  They style and format. 

 

onClick is a specific event that fires when you "click".  The event that matches "hovering" is the "onMouseOver" event, so you can run javascript code when you mouseover an object in the same way that you can run code when you click on an object.

Link to comment
Share on other sites

@haku, That is not what I want to achieve.  That is all the code you need to see what I'm trying to do.

 

Onclick it will expand the image from the default set 75x75pixels to auto (100%)

 

What I'm trying to do is revert back to its default size onclick.

 

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Funny Pictures</title>
<script type="text/javascript" src="Interactive.js"></script>
<link rel="stylesheet" type="text/css" href="style.css" />
</head>

<body>

<a class="image" onClick="this.className = 'new_class'; return false;"><img src="Pics/batman.png" alt="I'm Teh Batman!" /></a>

</body>
</html>

 

Javascript

onClick="this.className = 'image-expand'";

 

Css.

 

a.image img
{
width:75x;
height:75px;
}

a.image-expand
{
border:0;
position:center;
width:auto;
height:auto;
z-index:10000;  
}

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.