2014-09-10 55 views
0

如何使用JavaScript來調用其他JavaScript像這樣的代碼?如何使用JavaScript來調用其他JavaScript像這樣的代碼?

.............................................. .................................................. .................................................. ...................

http://jsfiddle.net/peap/bjdq3oL3/1/

<script src="http://code.jquery.com/jquery-1.7.2.js"></script> 
<form method="post" id="form_content" action="Javascript:void(0);"> 
    <button id="desc" name="desc" value="desc" style="display:none;">desc</button> 
    <button id="asc" name="asc" value="asc">asc</button> 
</form> 

<script> 
$(document).ready(function(){ 
    $('#form_content button').click(function(){ 
     $('#form_content button').toggle(); 
     var numbers = this.id; 
     function_two(); 
    }); 
}); 

function_two(){ 
     alert('numbers'); 
} 
</script> 

回答

3
function_two(){ 
    alert('numbers'); 
} 

需要被聲明爲函數

function function_two(){ 
    alert('numbers'); 
} 

http://jsfiddle.net/bjdq3oL3/2/

+0

我可以提醒'var numbers'嗎? – 2014-09-10 10:45:39

+0

@การการการนานานายานายา是的,你也可以。看看小提琴代碼。 http://jsfiddle.net/bjdq3oL3/3/ – Spokey 2014-09-10 10:46:30

+0

'var numbers'平均值按鈕,我點擊。從'var numbers = this.id;' – 2014-09-10 10:48:11

相關問題