+ 5

Difference between both method ? Is 2nd method is not the correct way to use? btw both working fine

//Getting current src value of img using event object var imgSrc = e.target.getAttribute('src'); //Getting current src value of img using event object without getAttribute var imgSrc = e.target.src;

24th Oct 2017, 12:05 PM
Amrendra Kumar
Amrendra Kumar - avatar
1 Answer
+ 3
Better use direct method, more readable and faster response. And old IE8 might not support get/setAttribute.
24th Oct 2017, 12:52 PM
CalviŐČ
CalviŐČ - avatar