BastienSander
BastienSander

Reputation: 1838

Jquery/firefox - animate div + show p select the text p?

I didn't find anyone who has the same problem and it is a really strange one.

It's not simple to explain so i give you the link bellow a little explanation.

First, here is my code:

<script type="text/javascript">
var close_feedback_box = function(){
    $jquery('div#feedback').removeClass('feedback_bigger').animate({
    top:'200px',width:'28px',height:'106px'}).find('p').hide();
    $jquery('div#close_feedback_box').hide('fast'); 
}
$jquery(document).ready(function(){
    $jquery('div#feedback a').hover(function(){
    $jquery(this).addClass('hover');},function(){
            $jquery(this).removeClass('hover');
    });
    $jquery('div#feedback').click(function(){
    if(!$jquery(this).hasClass('feedback_bigger')){
    $jquery(this).addClass('feedback_bigger').animate({
            top:'147px',width:'300px',height:'212px'
    },function(){
            $jquery('div#feedback p').show()});
            $jquery('div#close_feedback_box').fadeIn('slow');
    }
    });
});
</script>

<!-- feedback -->
<div id="close_feedback_box" onclick="close_feedback_box();"></div>
<div id="feedback" style="">
<p style="margin-top:30px;display:none;">You can take a few minutes to help us
     improve user experience
    <br/>and<br/><a id="">fill out our survey</a><br/>or<br/>
<a href="/index.php?option=com_jumi&fileid=11" id="">submit a direct feedback
    </a></p></div><!-- end feedback -->

It works very well in all browser but just have a look in firefox and you will understand my problem, in fact when the p block is show it select all the text and i really don't understand why. I tried to put the p block in a inner-feedback div (and show the div) and it doesn't change anything.

You will find the bug here (only in firefox) : https://execboardinasia.com/ (Click on the feeback 'button' in the left fixed position).

Thanks a lot for spending a bit of your time for me !

Bastien Sander

Upvotes: 0

Views: 451

Answers (1)

zoranc
zoranc

Reputation: 2456

for a workaround try adding

var select = window.getSelection();
select.removeAllRanges();

at the end of your click()

this should deselect the text...

Upvotes: 1

Related Questions