새소식

Front

[javascript] new Image() option (style & src & onclick)

  • -
728x90

new  Image() option
style & src & onclick


1
2
3
4
5
6
7
// JavaScript Code  
<script>
  img = new Image();
  img = "200px";
  img.src = 'blah.png';
  img.style.height = "140px";
  img.onclick = function() { alert('hi'); };
</script>


thanks~!


by doctorson0309, platformaker


reference : https://stackoverflow.com/questions/3316207/add-onclick-event-to-newly-added-element-in-javascript

reference : http://ontheinfo.com/2396#comment-9787

반응형
Contents

포스팅 주소를 복사했습니다

이 글이 도움이 되었다면 공감 부탁드립니다.