I am building a web application using ExtJS4 and I want to be able to get the source of an image element. I know I can use the line:
document.getElementById("imageID").getAttribute('src');
However, the issue I have with that solution is that the code is dependent on the id
property. I won't be able to reuse this code if I have an class with a panel and an image inside since I will have conflicting ids if I duplicate the class. What I resorted to instead is to set an itemID in the image inside my panel.
Is there a way to get the image source using only the itemID property? Or do i really have to stick with my the id property?
I got it:
Navigate to your image element and assign it to a variable then do:
imgSrc1 = img.getEl().getAttribute('src');
where img is your image variable