dongtigai3875 2017-06-12 13:04
浏览 31
已采纳

正确使用“在这个变量中

I cant figure out how i have to put the strings in this variable to let it work.

$button_uploader = '<button class="uploader_button" onclick="location.href='uploader.php' type="button">Upload hier je antwoorden</button>';
  • 写回答

4条回答 默认 最新

  • dsce23640 2017-06-12 13:12
    关注

    If you realy want to do that, use antislash character. Ex : \'upload.php\'

    But I suggest to you to not insert your javascript here and create separed file.

    Look at something like that :

    php/html, add id attribute to your button :

    $button_uploader = '<button id="my_uploader_button" class="uploader_button" type="button">Upload hier je antwoorden</button>';
    

    js :

    var my_uploader_button = document.getElementById('my_uploader_button');
    
    my_uploader_button.addEventListener('click', function() {
    window.location.href='uploader.php';
    });
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(3条)

报告相同问题?