Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
私は現在、HTMLとJavaScriptで作業しています。私は初心者です。HTMLファイルにあるボタンのonclickイベントでjavascriptファイルを開きたいです。これを行う方法はありますか?親切に私を助けてください。
前もって感謝します。
開くのではなく「ロードする」という意味だと思います
次のコードを使用して、JSファイルを動的に「ロード」できます
var fileref = document.createElement('script') fileref.setAttribute("type","text/javascript") fileref.setAttribute("src", yourfilename)