Selectors/API/jQuery - Sample Code
prev + next
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<script src="/jquery/js/jquery.js"></script>
<script>
$(document).ready(function(){
$("label + input").css("color", "red");
});
</script>
</head>
<body>
<form>
<label>名前:</label>
<input name="name" value="色が変わります" />
<fieldset>
<label>ニュース:</label>
<input name="newsletter" value="色が変わります" />
</fieldset>
</form>
<input name="none" value="labelの次では無いので変わりません" />
</body>
</html>
[実行結果]