开发者

Jquery if checked load html

Hey All, Thanks in advance for taking a look at my challenge. I've been wrestling with it for a couple days now and could really use a hand.

The Situation: When the user clicks a checkbox, I would like to populate the "div#partners_internal_products_registration" with the HTML contents specific to that checkbox. If the user decides the would like to made a d开发者_Go百科ifferent selection the new content will replace the existing content in the same

JS fiddle demo


Try this:

var checkboxes = $(':checkbox.productselect');
checkboxes.click(function(){
  checkboxes.attr('checked', false);
  $(this).attr('checked',true);
  $('#selection'+this.id+'content').load('1.html');
  //this is under the assumtion that every checkbox has the id of the content u want to update
})

It will 1st set ALL to false, then set the one u want to checked.

UPDATE

look above


$('#selection1').change({
       if($(this).test(":checked")) {
             $('#selectioncontent').load('1.html');
       }
       uncheckAll();
});

function uncheckAll() {
    $(':checkbox.productselect').each(fnction() {
        $(this).attr("checked",false);
    });
}

this should work

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜