User Tools

Site Tools


vpfjsphp:creating_dom_elements_with_events
<ul class="selecteur">
  <li><img src="img_1.jpg" /></li>
  <li><img src="img_2.jpg" /></li>
  <li><img src="img_3.jpg" /></li>
</ul>

document.querySelector(".selecteur").addEventListener("mouseover", function(e) {
  var mon_element = document.createelement('div');
  mon_element.id = "mon_id";
  mon_element.className = "ma_classe";
  e.target.parentNode.appendChild(mon_element);
  
  var mon_image = document.createElement("img");
  var image_location = e.target.src;
  mon_image.src = image_location.substr(0, image_location.length-7) + '.jpg';
  mon_element.appendchild(mon_image);
}, false);
vpfjsphp/creating_dom_elements_with_events.txt · Last modified: 2016/03/06 12:50 by leo