0

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?

2 Answers 2

2
$('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();
    });
Sign up to request clarification or add additional context in comments.

1 Comment

Thanks! #1 solved. I guess I did not phrase #2 well. What I am hoping to select it in the same way JavaScript select(); works on a text input's content so user can right-click to copy.
0

Use hover(). It's built for that.

$('#tipper').hover(function(){...on state..},function(){...off state...})



$('#tipper').click(function() {
  var myText = $('.tipdiv').html();
   alert(myText)
}

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.