【HTML】
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta http-equiv="content-type" content="text/html;charset=utf-8">
<title>jQuery Sample</title>
<link rel="stylesheet" href="css/main.css" type="text/css" media="all">
<script type="text/javascript" src="js/jquery.js"></script>
<script type="text/javascript" src="js/main.js"></script>
</head>
<body>
<h1>jQueryサンプル</h1>
<p>jQueryとは?</p>
<form>
<input type="button" value="書き替え" onClick="changeCSS()">
</form>
</body>
</html>
【CSS】
h1 {
font-size:14pt;
border-bottom:1px dotted gray;
width:320px;
}
【JavaScript】
function changeCSS(){
$("p").css("color", "#ff0000").css("background-color", "#000080");
}
【CSS】
h1 {
font-size:14pt;
border-bottom:1px dotted gray;
width:320px;
}
p {
color:green;
}
【JavaScript】
function getCSSValue(){
var cssValue = $("p").css("color");
alert("色の値は「"+cssValue+"」です");
}
【HTML】
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta http-equiv="content-type" content="text/html;charset=utf-8">
<title>jQuery Sample</title>
<link rel="stylesheet" href="css/main.css" type="text/css" media="all">
<script type="text/javascript" src="js/jquery.js"></script>
<script type="text/javascript" src="js/main.js"></script>
</head>
<body>
<h1>jQueryサンプル</h1>
<p>jQueryとは?</p>
<form>
<input type="button" value="書き替え" onClick="changeCSS()">
</form>
</body>
</html>
【CSS】
h1 {
font-size:14pt;
border-bottom:1px dotted gray;
width:320px;
}
【JavaScript】
function changeCSS(){
$("p").css({ "color" : "#ff0000", "background-color" : "#000080"});
}