اجرای کد
تغییر قالب
تغییر موقعیت
خانه
×
Change Orientation
Change Theme, Dark/Light
<!DOCTYPE html> <html dir="rtl"> <body> <h1>عنصر template در HTML</h1> <p>برای نمایش محتوای پنهان از عنصر template ، روی دکمه زیر کلیک کنید.</p> <button onclick="showContent()">نمایش محتوای مخفی</button> <template> <h2>گل</h2> <img src="https://www.bubbleslearn.ir/wp-content/uploads/2021/07/img_white_flower.jpg" width="214" height="204"> </template> <script> function showContent() { var temp = document.getElementsByTagName("template")[0]; var clon = temp.content.cloneNode(true); document.body.appendChild(clon); } </script> </body> </html>