تغيير الخصائص عند الحالتين focus & blur
<!DOCTYPE html>
<html>
<head>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"></script>
<script>
$(document).ready(function(){
$("input").focus(function(){
$(this).css("background-color", "#ccc");
});
$("input").blur(function(){
$(this).css("background-color", "#fff");
});
});
</script>
</head>
<body>
Name: <input type="text" name="fullname"><br>
Email: <input type="text" name="email">
</body>
</html>
يمكننا تغيير خصائص أي عنصر من عناصر html
<!DOCTYPE html>
<html>
<head>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"></script>
<script>
$(document).ready(function(){
$("button").click(function(){
$("body").css("background-color", "#0f0");
});
});
</script>
</head>
<body>
<button>show</button>
</body>
</html>
<!DOCTYPE html>
<html>
<head>
<style>
img {
width:20%;
height:20%
}
</style>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"></script>
<script>
$(document).ready(function(){
$("button").click(function(){
$("img").css("width", "40%");
});
});
</script>
</head>
<body>
<div>
<img src="https://farm4.staticflickr.com/3894/15008518202_b016d7d289_m.jpg" />
<button>resize </button>
</div>
</body>
</html>