Nhận JavaScript hình ảnh

Given an HTML element and the task is to create an element and append it to the document using JavaScript. In these examples when someone clicks on the button then the element is created. We can replace the click event with any other JavaScript event. 

Cách tiếp cận 1

  • Tạo phần tử img trống bằng tài liệu. phương thức createElement[]
  • Sau đó đặt các thuộc tính của nó như [src, height, width, alt, title, v.v.]
  • Cuối cùng, chèn nó vào tài liệu

ví dụ 1. Ví dụ này thực hiện cách tiếp cận trên.  

html




 

    

Chủ Đề