https://www.w3schools.com/js/tryit.asp?filename=tryjs_dom_imageこれはjsでhtmlコンテンツを変更することについてですが、画像についてです。このようなことも可能ですか?同じですが、新しいhtmlファイルを使用して、ページ内のページを切り替えることができますか?したがって、計画では、jsを使用して下のhtml(id = "id")を別のhtmlファイルに置き換える予定です。
document.getElementById("id").src = "otherfile.html";
<html>
<body>
hey guys! here is my html page. If you click underneath, content will be changed.
<html id="id">
<body>
here is the text that will change if id="id" will be changed by a different html file
</body>
</html>
</body>
</html>
もちろん、これはうまくいかないことを私は知っています。しかし、これをアーカイブする方法はありますか?
あなたが読んでいて、trynnaが私の投稿に答えてくれたらありがとう、それが厄介でくだらない質問であるかどうか理解しているので、あなたに叫びなさい。
div
代わりに全体の内容を変えてみHTML
ませんか?jQuery経由。
<div id="dynamic-html">
here is the text that will change if id="id" will be changed by a different html file
</div>
$( "#btnChangeHTML" ).click(function() {
$( "#dynamic-html" ).html("<div class='myclass'>This is the custom HTML</div>");
});
ここにフィドルがあります:
この記事はインターネットから収集されたものであり、転載の際にはソースを示してください。
侵害の場合は、連絡してください[email protected]
コメントを追加