Reputation: 22018
Two jQuery questions:
1) Given this HTML structure
<div id="tipper" class="tiplink"><a href='test.html' >Link Text</a>
<div id="tip" class="tipdiv">This is the tool tip text.</div>
</div>
How can I alter these to work on classes so that that when a div of class .tiplink
is moused over the div of class .tipdiv
inside it is targeted?
$(document).ready(function(){
$('#tipper').mouseover(function() {
$('#tip').clearQueue().show(0);
});
$('#tipper').mouseleave(function() {
setTimeout( function(){
$('#tip').hide(0);
},20000);
});
2) Without using a text input is it possible to select all the text in .tipdiv
on click?
Upvotes: 0
Views: 1470
Reputation: 10572
$('div.tiplink').mouseover(function() {
$(this).find('div.tipdiv').clearQueue().show(0);
});
and for the click
$('div.tiplink').click(function() {
var text = $(this).find('div.tipdiv').text();
});
Upvotes: 2
Reputation: 114417
Use hover()
. It's built for that.
$('#tipper').hover(function(){...on state..},function(){...off state...})
$('#tipper').click(function() {
var myText = $('.tipdiv').html();
alert(myText)
}
Upvotes: 0