2011-07-10 9 views
0

私は、ボタンの位置に応じて変化するクラスを持つボタンを使用しています。ボタンがオンの場合、クラスは "ボタンオン" "button off"ボタンのクラスを使用したJqueryページのコンテンツのリロード

デフォルトではボタンがオンになっているので、特定のタイプの情報がデータベースからロードされますが、誰かがクリックすると、データベースから別のタイプの情報をロードします。私はどのようにクラス変更トリガー情報の読み込みを行うか分からない。私は全体のページがちょうどそれの内容をリロードすることを望んでいない、と私はどのようにわからない! jQueryでも可能ですが、何か他のことをしなければなりません。ページのリロードなしでいくつかのデータを取得するために//www.webstuffshare.com/2010/03/stylize-your-own-checkboxes/

答えて

0

ます:http:

私は、ボタンのためにこのサイトにあるスクリプトを使用していますあなたは、クラスを変更する方法を指定してください遺骨をトリガーについて質問した場合

$.ajax({ 
    url: "test.html", 
    success: function(data){ 
    $("#some_id").html(data); 
    //or make whatever manipulations you want 
    } 
}); 

:あなたはjquery.ajax()関数を使用することができます。

if(jQuery(this)[0].checked == true) { 
    jQuery(this).after('<div class="'+ setClass +' on" rel="'+ thisID +'">&nbsp;</div>'); 
    //here the request for one data 
    $.ajax({ 
    url: "one url", 
    success: function(data){ 
     $("#some_id").html(data); 
    } 
    }); 
} 
else { 
    jQuery(this).after('<div class="'+ setClass +' off" rel="'+ thisID +'">&nbsp;</div>'); 
    //and here - for another 
    $.ajax({ 
    url: "another url", 
    success: function(data){ 
     $("#some_id").html(data); 
    } 
    }); 

} 
+0

このようにクラスを変更すると、チェックボックスがオンになっているかどうかが検出されます。 if(jQuery(this)[0] .checked == true) jQuery(this).after( '

 
'); 他\t \t \t \t \t \t jQueryの(この).after( '
 
'); – Samantha

関連する問題