开发者

How to use Hover and click using Jquery

开发者 https://www.devze.com 2023-04-04 11:16 出处:网络
Hi all i am using the hover and click function for a tool tip from here ToolTips Now as per my requirement i would like to combine both hover and click event in one method. When hover i don\'t want

Hi all i am using the hover and click function for a tool tip from here

ToolTips

Now as per my requirement i would like to combine both hover and click event in one method. When hover i don't want to show close button but when user click i would like to show close button. How can i do this in one event can any help me or if any examples or samples please share

I tried this for Tooltip on Click

<script type="text/javascript">
  $(document).ready(function() {
     $('#foobar2').click(function() {
      var url = $(this).attr('href');       
      $(this).formBubble({
        url: url,
        dataType: 'html',
        cache: false
      });

      return false;
    });
  });
</script>

I tired this but not working can you edit please

 <script type="text/javascript">
  $(document).ready(function() {
  $('#foobar2').bind('mouseover click',function(e) {
    if(e.Type=='click')
    {
    var url = $(this).attr('href');

      $(this).formBubble({
        url: url,
        dataType: 'html',
        cache: false
      });

      return false;
    }


      if(开发者_开发百科e.Type=='mouseover')
      {
      var url = $(this).attr('href');

      $(this).formBubble({
      closebutton:false;
        url: url,
        dataType: 'html',
        cache: false
      });
      $.fn.formBubble.text('hover hover hover hover');
    }, function() { //mouse out
      var thisBubble = $.fn.formBubble.bubbleObject;

      $.fn.formBubble.close(thisBubble);
    });
      }   

    });});
</script>

hi i tried this but didn't work

 if(e.type=='mouseout')
{
var url = $(this).attr('href'); 
$(this).formBubble.hide()
}


instead of binding with: .click(function(){ ... })

bind with: .bind('mouseover click',function(e){ ... })

then inside the function use: e.type which will be a string determining what event type was triggered

<script type="text/javascript">
  $(document).ready(function() {
     $('#foobar2').bind('mouseover click',function(e) {

      if(e.type == 'click'){
        // do some click event stuff
        var close = true 
      } else {
        // do some hover event stuff
        var close = false 
      }

      var url = $(this).attr('href');       
      $(this).formBubble({
        url: url,
        dataType: 'html',
        cache: false,
        closeButton: close
      });

      return false;
    });
  });
</script>
0

精彩评论

暂无评论...
验证码 换一张
取 消