PDA

View Full Version : نحوه فراخوانی یک استایل؟؟؟



teshnehab
چهارشنبه 22 دی 1389, 00:17 صبح
من این کد را در یک فایل css دارم:


.Pic
{
position:relative;
float:left;
left:30px;
height: 44px;
width: 82px;
background-image: url('../image/M1.jpg');
background-repeat: no-repeat;
cursor:pointer;
}

حالا میخوام با کلیک بر روی یک دکمه این تغییرات در صفحه وب من اعمال بشه که کد زیر را نوشتم :


<div class="Pic" onclick=".........................."></div>

اما نمیدونم در قسمت onclick چی بنویسم.اساتید راهنمایی میکنند؟

hossin.esm
شنبه 25 دی 1389, 13:17 عصر
<!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>Untitled Document</title>
<script type="text/javascript">
function test(th)
{
th.style.background="url('2.png') no-repeat";
th.style.cursor="pointer";
th.style.position="relative";
th.style.float="left";
th.style.left="30px";
th.style.height="44px";
th.style.width="82px";

}

</script>
</head>
<body>
<div class="Pic" onclick="test(this)" style="width:100px;height:100px;border:thin #999 solid;"></div>
</body>
</html>