2014-09-04 78 views
0

這裏的塊就是我想要的(jQuery的,HTML)做:使用開關添加HTML

目的是讓這個HTML的時候我打的開關(基本/高級)塊被添加到現有的HTML。在這個新的塊中將會有另一個開關(更少/更多),這應該增加另一個塊。

但是,我似乎無法(少/多)切換到工作。事實上,該功能根本沒有運行。

對應於(基本/高級)開關的功能是:

var selectInvestment = "basic"; 
function expandInvestment(){ 
    $("input[type=radio][name=expandInformation]").click(function(){ 
     selectInvestment = $(this).val(); 
     var huge = 'huge block of html code in here'; 
     if(selectInvestment == "advanced"){ 
      $('.investmentBlock').empty(); 
      $('.investmentBlock').append(huge); 
      expandedExpenses(); 
     } else if(selectInvestment == "basic"){ 
      $('.investmentBlock').replaceWith("<...more html code...>"); 
     } 
    }); 
} 

而且這對於不太/更多開關相似。

這裏是jsfiddle預覽。 http://jsfiddle.net/1g6uraht/1/

+0

看到控制檯'未捕獲的ReferenceError: repaymentSelection is not defined',if it – Mritunjay 2014-09-04 02:17:39

+1

fwiw,你可以通過在'