Пример:
По нажатию установить css свойство width для каждого элемента div в 30 px и изменить цвет текста.
"jQuery"
$("div").one('click', function () { $(this).width(30) .css({cursor:"auto", "background-color":"blue"}); });
"HTML"
<div></div> <div>d</div> <div>d</div> <div>d</div> <div>d</div>
"CSS"
div { width:70px; height:50px; float:left; margin:5px;
background:red; cursor:pointer; }
"Живой пример jQuery"
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<link href="http://slyweb.ru/css/jqueryiframe.css"
rel="stylesheet" type="text/css"/>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.5.0/jquery.min.js"></script>
<script>
$(document).ready(function(){
$("div").one('click', function () {
$(this).width(30)
.css({cursor:"auto", "background-color":"blue"});
});
});
</script>
</head>
<body class="iframe">
<div></div>
<div>d</div>
<div>d</div>
<div>d</div>
<div>d</div>
</body>
</html>
<style>
div { width:70px; height:50px; float:left; margin:5px;
background:red; cursor:pointer; }
</style>