Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to use jquery to change button states over multiple images
    primarykey
    data
    text
    <p>I was wondering what is the proper way of using jquery to change HyperLinkImage States, i.e mousedown, onmouseup etc...other than copying and pasting the same function and changing id names? Here is the code that I was just going to copy and paste and change the clientid parts to reflect 5 other image links</p> <pre><code>$(function () { $("#&lt;%=HyperLink1.ClientID%&gt; img").hover(function () { $(this).attr("src", "/HoverIcons/Icon_lab.png"); }, function () { $(this).attr("src", "/ActiveIcons/Icon_lab_a.png"); }).mousedown(function () { $(this).attr("src", "/DownIcons/iconlab.png"); }).mouseup(function () { $(this).attr("src", "/ActiveIcons/Icon_lab_a.png"); }); }); </code></pre> <p>Is there a cleaner way to do this? </p> <p>Here is the part where all the links are in my markup..</p> <pre><code>&lt;div id="Navigation1"&gt; &lt;div id="Nav"&gt; &lt;table style="width: 100%;"&gt; &lt;tr&gt; &lt;td&gt; &lt;asp:HyperLink ID="HyperLink1" runat="server" ImageUrl="~/ActiveIcons/Icon_lab_a.png" NavigateUrl="~/Tabbet.aspx"&gt;HyperLink&lt;/asp:HyperLink&gt; &lt;/td&gt; &lt;td&gt; &lt;asp:HyperLink ID="HyperLink2" runat="server" ImageUrl="~/ActiveIcons/Icon_ABC_a.png"&gt;HyperLink&lt;/asp:HyperLink&gt; &lt;/td&gt; &lt;td&gt; &lt;asp:HyperLink ID="HyperLink3" runat="server" ImageUrl="~/ActiveIcons/Icon_math_a.png"&gt;HyperLink&lt;/asp:HyperLink&gt; &lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td&gt; &lt;asp:HyperLink ID="HyperLink4" runat="server" ImageUrl="~/ActiveIcons/Icon_english_a.png"&gt;HyperLink&lt;/asp:HyperLink&gt; &lt;/td&gt; &lt;td&gt; &lt;asp:HyperLink ID="HyperLink5" runat="server" ImageUrl="~/ActiveIcons/Icon_history_a.png"&gt;HyperLink&lt;/asp:HyperLink&gt; &lt;/td&gt; &lt;td&gt; &lt;asp:HyperLink ID="HyperLink6" runat="server" ImageUrl="~/ActiveIcons/Icon_geography_a.png"&gt;HyperLink&lt;/asp:HyperLink&gt; &lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td&gt; &lt;asp:HyperLink ID="HyperLink7" runat="server" ImageUrl="~/ActiveIcons/Icon_cyberspace_a.png"&gt;HyperLink&lt;/asp:HyperLink&gt; &lt;/td&gt; &lt;td&gt; &lt;img alt="" class="auto-style3" src="ActiveIcons/New_subject_coming.png" /&gt;&lt;/td&gt; &lt;td&gt; &lt;img alt="" class="auto-style3" src="ActiveIcons/New_subject_coming.png" /&gt;&lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td&gt;&amp;nbsp;&lt;/td&gt; &lt;td&gt;&amp;nbsp;&lt;/td&gt; &lt;td&gt;&amp;nbsp;&lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td&gt; &amp;nbsp;&lt;/td&gt; &lt;td&gt;&amp;nbsp;&lt;/td&gt; &lt;td&gt;&amp;nbsp;&lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td&gt;&amp;nbsp;&lt;/td&gt; &lt;td&gt;&amp;nbsp;&lt;/td&gt; &lt;td&gt;&amp;nbsp;&lt;/td&gt; &lt;/tr&gt; &lt;/table&gt; &lt;/div&gt; </code></pre> <p>I'm just starting to change the code now, this is my layout for the images.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload