jquery - anchor icon, with hide div, change on hover and on click -
i have anchor point toggles hiden div. i'm being able of changing anchor icon when hover on (i've done sprite) i'm not capable of adding second .click event wich let me change anchor it's 'btn_close' icon.
want code do:
hover on 'btn_open'------it changes 'btn_open':hover
click on 'btn_open'------it changes 'btn_close' , toggles hiden div
hover on 'btn_close'------it changes 'btn_close':hover
click on 'btn_close'------it changes 'btn_open' , toggles hiden div
i did fiddle simplifying problem (showing point reach).
http://jsfiddle.net/weberjavi/72xsl/
html:
<body> <a href="#" class="btn_open">open</a> <div id="content"></div> </body>
jquery:
$("#content").hide(); $(".btn_open").click(function () { $("#content").toggle("slow"); return false; });
thanks everyone.
try i'm not sure if it's you're trying do
adding toggle change classes of button removing 1 if it's on element , adding if not.
i attached handler elements class starts btn
make work both btn_close
, btn_open
$("#content").hide(); $("[class^=btn]").click(function () { $(this).toggleclass("btn_open btn_close") if($(this).hasclass("btn_close")){ $(this).text("close") }else{ $(this).text("open") } $("#content").toggle("slow"); return false; });
Comments
Post a Comment