Jquery css function to dynamically manipulate the style of DOM nodes
The css function in JQuery can set effects for DOM nodes. CSS functions generally have the following uses:
1. Determine whether an object is hidden:
$("#id").css("display")=="none " ;
Second, set the value of a style attribute in all matching elements:
$("div").css("color","#FF0000");
Three, put a "name/value pair" Object set to the style properties of all matching elements. This is the best way to set a large number of style
attributes on all matching elements:
$("div").css({ color: "#ff0000", background: "blue" });
If the attribute name If it contains "-", you must use quotation marks:
$("div").css({ "margin-left": "10px", "background-color": "blue" });
Here are some of what I wrote demo code.
[html] <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <meta name="author" content="LuisZhang"> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> <title></title> <script type="text/javascript" src="js/jquery-1.4.2.min.js"></script> <script type="text/javascript"> $(function() { // $("div").click(function() { alert($(this).next("div").text()); }); // $("div").click(function() { alert($(this).nextAll("div").text()); }); // $("div").click(function() { $.each($(this).nextAll("div"), function() { $(this).css("background", "red") }); }); $("p").click(function() { $.each($(this).nextAll("p"), function() { $(this).css("background", "#abccdd") }); }); $("div").click(function() { $.each($(this).next("div"), function() { $(this).css({ "margin-left": "10px", color: "#abccdd", background: "blue" }) }); }); $("#fristDiv").click(function() { $.each($(this), function() { $(this).css({ "margin-left": "10px", color: "#abccdd", background: "blue" }) }); }); $("#lastDiv").click(function() { $.each($(this), function() { $(this).css({ "margin-left": "10px", color: "#abccdd", background: "blue" }) }); }); }); </script> </head> <body> <div id="fristDiv">aa</div> <div>bb</div> <div>cc</div> <div>dd</div> <p>p1</p> <p>p2</p> <p>p3</p> <p>p4</p> <div id="lastDiv">ee</div> </body> </html>

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)
