2014-11-24 82 views
1

我無法正確工作,你可以看到下面的代碼,它似乎只是爲一個鏈接工作,它只會加載index.php?act =老...jQuery不能正常工作點擊,只有一個元素

$(document).ready(function(){ 

     $("#example").dialog({modal: true}); 
     $("#example").dialog({width: 500}); 

     $('#newProject').click(function(){ 
      $('#dialogContent').load('index.php?act=new'); 
     }); 

     $('#oldProject').click(function(){ 
      $('#dialogContent').load('index.php?act=old'); 
     }); 

    }); 

和HTML

<div id="example" title="Create new project or open old project?" style="display:none"> 
<div id="dialogContent"> 
Would you like to create a new calculation or open and edit and old calculation?<br /><br /> 
<a href="#" id="oldProject">Open Old Calculation</a><br /><br /><a href="#" id="newProject">Create New Calculation</a> 
</div> 
</div> 
+0

你確定這兩個環節的工作? JS是否加入事件處理程序? – 2014-11-24 22:09:44

+0

你如何測試它? – 2014-11-24 22:11:24

+0

任何一個我點擊?act = old是唯一一個將加載到對話框內容DIV – user1888260 2014-11-24 22:11:46

回答

1

嘗試禁用鏈接的默認行爲:

$('#newProject').click(function(event) 
{ 
    event.preventDefault(); 
    $('#dialogContent').load('index.php?act=new'); 
}); 

$('#oldProject').click(function(event) 
{ 
     event.preventDefault(); 
     $('#dialogContent').load('index.php?act=old'); 
}); 
相關問題