これは単純な状況であり、おそらくある程度一般的であると確信していますが、私は立ち往生していて、それを理解できないようです.
チェックボックスに jQuery UI Buttons を使用しています。ユーザーがいずれかをクリックすると、jquery がページの下部にある対応する div に変更を加えるようにします。最終的には、.load を使用して div に別のページのコンテンツを入力する予定ですが、今のところ、背景色を変更するだけです。
以下は、私が動作させようとしているコードです。私は jQuery が苦手で、簡単な間違いを犯している可能性があります。
ご協力いただきありがとうございます。
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8" />
<title>jQuery UI Button - Checkboxes</title>
<link rel="stylesheet" href="http://code.jquery.com/ui/1.10.3/themes/smoothness/jquery-ui.css" />
<script src="http://code.jquery.com/jquery-1.9.1.js"></script>
<script src="http://code.jquery.com/ui/1.10.3/jquery-ui.js"></script>
<link rel="stylesheet" href="/resources/demos/style.css" />
<script>
$(document).ready(function() {
$(function() {
$( "#check" ).button();
$( "#format" ).buttonset();
});
});
$('input:checkbox').change(function(){
if($(this).is(':checked')){
alert('checked');
$("#first").css("background-color","yellow");
} else {
alert('un-checked');
$("#first").css("background-color","red");
}
});
</script>
<style>
#format { margin-top: 2em; }
</style>
<div id="format">
<input type="checkbox" id="check1" /><label for="check1">1</label>
<input type="checkbox" id="check2" /><label for="check2">2</label>
<input type="checkbox" id="check3" /><label for="check3">3</label>
</div>
<!-- The following divs will end up being populated via an ajax call based on checkbox selections -->
<!-- Ultimately, checking a given checkbox should toggle the corresponding div -->
<div id="first">
</div>
<div id="second">
</div>
<div id="third">
</div>