Reputation: 17049
Here's a fiddle of my problem, and a code snippet in case that doesn't work:
$(function() {
$('div').hover(
function() {
$(this).append("<div id='xxx'>ccc</div>")
},
function() {
$('#xxx').remove();
});
});
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.10.0/jquery.min.js"></script>
<table>
<tr>
<td>
<div>
<a href="xxx">
<img src="xxx">aaa
</a>
bbb
</div>
</td>
</tr>
</table>
When I hover out of div, Text part of the link aaa
disappears. I becomes :hover{visibility:visible}
for some reason.
It has nothing to do with elements ids or text or links.
It is Chrome problem, Firefox works as should.
Is it a bug or it is a js problem here? Why does Chrome do that?
Upvotes: 4
Views: 113
Reputation: 348
Try using this:
$('div').hover(
function() {
$(this).parent().append("<div id='xxx'>ccc</div>");
},
function() {
$('#xxx').remove();
}
);
Upvotes: 1
Reputation: 460
user after method to solve this problem
<script>
$('div').hover(
function() {
$(this).after("<div id='xxx'>ccc</div>")
},
function() {
$('#xxx').remove();
}
);
</script>
Upvotes: 2
Reputation: 5079
Surrounding 'bbb' with span
fixes the problem:
$(function() {
$('div').hover(
function() {
$(this).append("<div id='xxx'>ccc</div>")
},
function() {
$('#xxx').remove();
});
});
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.10.0/jquery.min.js"></script>
<table>
<tr>
<td>
<div>
<a href="xxx">
<img src="xxx">aaa
</a>
<span>bbb</span>
</div>
</td>
</tr>
</table>
Upvotes: 2
Reputation: 3709
Interesting behaviour. I've tried to add this, and text part of aaa
is showing.
function(){
$(this).clearfix:after {
/* visibility: hidden; */}}
Upvotes: 0