==jQuery Tips==
[[jQuery][JavaScript]]
*リファレンス http://docs.jquery.com/Main_Page
*リファレンス(日本語) http://semooh.jp/jquery/
===読み込み中メッセージを表示===
=====html=====
<<div id="loading" style="display:none">>計算中・・・<</div>>
=====style=====
<<style type="text/css">>
#loading {
position: absolute;
width:100px;
}
<</style>>
=====表示=====
$("#loading").show("normal");
:
<<blockquote>>ただし、XMLが文字列として取得されるので、jQuery でXMLとして利用するには、DOMへの変換が必要<</blockquote>>
=====XML文字列をDOMに変換するライブラリ=====
*http://outwestmedia.com/jquery-plugins/xmldom/
=====例=====
*http://jsbin.com/eqape
<<div id="hoge_panel">> <<h3><><a href="#">>タイトル 1<</a><></h3>> <<div>>test1<</div>> <<h3><><a href="#">>タイトル 2<</a><></h3>> <<div>>test2<</div>> <<h3><><a href="#">>タイトル 3<</a><></h3>> <<div>>test3<</div>> <<h3><><a href="#">>タイトル 4<</a><></h3>> <<div>>test4<</div>> <</div>>
$("#hoge_panel").addClass("ui-accordion ui-accordion-icons ui-widget ui-helper-reset")
.find("h3").addClass("ui-accordion-header ui-helper-reset ui-state-default ui-corner-top ui-corner-bottom")
.hover(function() { $(this).toggleClass("ui-state-hover"); })
.prepend('<<span class="ui-icon ui-icon-triangle-1-s"><></span>>')
.click(function() {
$(this)
.toggleClass("ui-accordion-header-active ui-corner-bottom")
.find("> > .ui-icon").toggleClass("ui-icon-triangle-1-e ui-icon-triangle-1-s").end()
.next().toggleClass("ui-accordion-content-active").slideToggle();
return false;
=====DOMを操作する(IEでもOK)=====
var selectBox = document.getElementById("selectboxId");
for (var i=0; i<<selectBox.options.length; i++) {
if (selectBox.options[i].value == targetCode) {
selectBox.options[i] = new Option(newName, targetCode);
==HTML(テーブル)==
===選択された行のセルのテキストを取得===
var tr = $("<<tr>>")
tr.click(function(){
var cols = $(this).children();
===テーブルの行が選択された時にラジオボタンをONにする。===
var tr = $("<<tr>>")
tr.click( function () {
$("#projects_table tbody tr").removeClass("selected_row");
// $.getJSON callback
function reload_date(json) {
if ($("#calc_expr_table tbody").length > > 0) {
$("#calc_expr_table tbody").remove();
}
$("#calc_expr_table").append("<<tbody><></tbody>>");
$("#calc_expr_table tbody").append(
"<<tr><><th>>プログラムサイズ(KLOC)<</th><><td>>" + json.kdsi + "<</td><></tr>>" + "<<tr><><th>>工数(PM)<</th><><td>>" + json.effort + "<</td><></tr>>" + "<<tr><><th>>開発期間(M)<</th><><td>>" + json.tdev + "<</td><></tr>>" + "<<tr><><th>>プログラムサイズ(KLOC)<</th><><td>>" + json.fsp + "<</td><></tr>>" + "<<tr><><th>>生産性(KLOC/PM)<</th><><td>>" + json.prod + "<</td><></tr>>"
);
}
=====HTML=====
<<table id="calc_expr_table"><></table>>
==CSS==
===クラスの追加===