jquery - Anchor in pulltab not working -
i've got interesting problem can't seem solve nor find answer either here or on web. straight problem:
i'm implementing pull-tab website alert visitors of information , link i'd them see. pull-tab working correctly problem lies anchor. when click it, nothing yet when right-click , open in new tab, goes desired url.
i have pull tab in div absolute position tab sticks out of left side of screen. here html , jquery i'm using feature work far:
<div class="pop-out-notice"> <div class="tab"> <svg xmlns="http://www.w3.org/2000/svg" width="15px" height="100px"> <rect xmlns="http://www.w3.org/2000/svg" x="0" y="0" width="15px" height="100px" fill="rgb(187, 187, 187)" stroke="none"></rect> <text xmlns="http://www.w3.org/2000/svg" x="-0" y="0" fill="rgb(255, 255, 255)" font-size="17" style="text-anchor: end; dominant-baseline: hanging; cursor: pointer;" transform="rotate(-90)" text-rendering="optimizespeed"> pull tab </text> </svg> </div> <div class="content"> <h3>60 second survey!</h3> take minute tailor library's website better meet needs:<br><br> <a href="[link here]">click here</a> </div> </div> <script type="text/javascript"> $(document).ready(function() { $('.pop-out-notice .tab').click(function(){ var popoutwidth = $('.pop-out-notice').css('left'); if(popoutwidth === '0px'){ $('.pop-out-notice').toggle(function(){ $(this).animate({'left': '-225px'}, 1000); }, function(){}); }else if(popoutwidth === '-225px'){ $('.pop-out-notice').toggle(function(){ $(this).animate({'left': '0px'}, 1000); }, function(){}); } }); }); </script>
if has suggestions problem might or ways clean code, i'd more happy try out.
thanks time , help/suggestions can give me!
after doing testing , further research. i've fixed both problems in above question. i've fixed link problem , i've cleaned code it's far simpler before. here changes have answered problem.
i switched code using animate class , instead used toggleclass class new css element mimics needed animate. here changed code:
jquery changes:
$(document).ready(function() { $('.pop-out-notice .tab').click(function(){ $('.pop-out-notice').toggleclass('pop-out-toggle'); }); });
css additions:
.pop-out-notice{ ... transition: 1.75s; } .pop-out-toggle{ left: 0px !important; }
i'm sure initial, convoluted, code had lot errors , funky things going on it. hope helps else stumbles upon similar situations.
Comments
Post a Comment