I’m new to web development and have been searching around for this exact issue but haven’t found any discussion yet. Basically I have an asp:ImageButton inside a repeater that I have created as below:
<asp:ImageButton onmouseover="MouseOverArr(this)" runat="server" ImageUrl='<%# Container.DataItem %>'/>
and the javascript function:
function MouseOverArr(image) {
image.style.opacity = 0.75;
}
However, this code does NOT work. If I instead do: onmouseover="this.style.opacity='0.75'" then it works. Also, if I change the function to get the id first and then use document.getElementById to retrieve the element then set opacity on that element, all is good. Why would the original code above not work?
My bad, the code I posted actually worked. I have a stupid typo in my actual project that causes the problem. Can’t believe I didn’t notice it sooner but must have been a long day. Thanks for all the suggestions.