2014-12-04 56 views
-1

我有一些代碼,使用輸入標籤備案錄音機和停止按​​鈕:HTML改變輸入標籤按鈕標籤

<input type="button" class="start" value="Record" /> 
<input type="button" class="stop" value="Stop" /> 

我想改變那些輸入標籤<按鈕>標籤執行相同的功能,但我不知道如何。代碼使用jquery,我認爲代碼中的實際功能是用jquery編寫的。下面是我認爲執行「開始」和「停止」功能的代碼部分:

$('.recorder .start').on('click', function() { 
    $this = $(this); 
    $recorder = $this.parent(); 

    navigator.getUserMedia({audio: true}, function(stream) { 
     var recorderObject = new MP3Recorder(audio_context, stream, { statusContainer: $recorder.find('.status'), statusMethod: 'replace' }); 
     $recorder.data('recorderObject', recorderObject); 

     recorderObject.start(); 
    }, function(e) { }); 
    }); 

    $('.recorder .stop').on('click', function() { 
    $this = $(this); 
    $recorder = $this.parent(); 

    recorderObject = $recorder.data('recorderObject'); 
    recorderObject.stop();  

該方案有其他.js文件,它使用時,需要這樣也許更多關於他們的信息來回答這個問題。我嘗試以下,但他們沒有工作:

<button onclick="start()">Record</button> 
<button class="start">Record</button> 
+0

是你'<按鈕類= 「開始」>記錄''裏面元素.recorder'? – Lekhnath 2014-12-04 16:47:39

回答

1

你需要一個父.recorder元素是這樣的:

<div class="recorder"> 
    <button class="start">Record</button> 
    <button class="stop">Stop</button> 
</div> 
+0

謝謝,這很好。我很感激幫助。 – user3080392 2014-12-04 17:01:39

0

這應該是好的,如果沒有其他的JS,那就是execude當您單擊按鈕原。

<button class="start">Record</button> 
<button class="stop">Stop</button> 
+0

謝謝,但我已經嘗試過,並沒有奏效。另外,我提到還有其他的.js文件。我瀏覽了他們,我發現的關於啓動和停止功能的唯一信息在函數中沒有任何信息。這是沿着「函數start(){}」的行,並沒有在函數內的信息。 – user3080392 2014-12-04 16:55:34