KyLim KyLim - 4 months ago 12
Javascript Question

elevatezoom not working after add runat="server"

<img id="zoom_01" src="Images/org_chart/admin.jpg" data-zoom-image="Images/org_chart/admin.jpg" width="700" height="700" />

<script>
$("#zoom_01").elevateZoom();
</script>
<script src="js/jquery.elevatezoom.js" type="text/javascript"></script>


My code is working fine,the image able to zoom in when mouse hover.
After i add in runat="server" in my img tag,it fail to zoom in.

<img id="zoom_01" src="Images/org_chart/admin.jpg" data-zoom-image="Images/org_chart/admin.jpg" width="700" height="700" runat="server" />

Answer

Rendered client id wont match server id. To get rendered id use: Control.ClientID

<script>
    $("#<%= zoom_01.ClientID %>").elevateZoom();
</script>
Comments