Syed Mujeeb
Syed Mujeeb

Reputation: 21

How to change onclick event to on mouseover

I am new to javascript I have a doubt in changing onclick event to mouseover
please help

<script>
$(document).ready(function() {

(function ($) {
  $.fn.readmore = function (settings) {

    var opts =  $.extend({}, $.fn.readmore.defaults, settings);

    this.each(function () {
      $(this).data("opts", opts);
      if ($(this).html().length > opts.substr_len) {
        abridge($(this));
        linkage($(this));
      }
    });

    function linkage(elem) {
      elem.append(elem.data("opts").more_link);
      elem.children(".more").click( function () {
        $(this).hide();
        $(this).siblings("span:not(.hidden)").hide().siblings("span.hidden").animate({'opacity' : 'toggle'},1000);
      });

    }

    function abridge(elem) {
      var opts = elem.data("opts");
      var txt = elem.html();
      var len = opts.substr_len;
      var dots = "<span>" + opts.ellipses + "</span>";
      var charAtLen = txt.substr(len, 1);
      while (len < txt.length && !/\s/.test(charAtLen)) {
          len++;
          charAtLen = txt.substr(len, 1);
      }
      var shown = txt.substring(0, len) + dots;
      var hidden = '<span class="hidden" style="display:none;">' + txt.substring(len, txt.length) + '</span>';
      elem.html(shown + hidden);
    }

    return this;
  };

  $.fn.readmore.defaults = {
    substr_len: 500,
    ellipses: '&#8230;',
    more_link: '<a class="more">Read&nbsp;More</a>'
  };

})(jQuery);

$(function(){
    $('.des_details').readmore({ substr_len: 150 });
});
});
        </script>


Any suggestions?

Upvotes: 2

Views: 3257

Answers (3)

Matthias Wegtun
Matthias Wegtun

Reputation: 1261

where you have

elem.children(".more").click( function ()

replace it with

elem.children(".more").hover( function ()

Upvotes: 1

Arun Bertil
Arun Bertil

Reputation: 4648

Try this code

$(urid).trigger('mouseover');

Upvotes: 0

Deej
Deej

Reputation: 105

There's a bit of API doc about .hover() which explains what I think you're trying to do. Hope this helps.

http://api.jquery.com/hover/

Upvotes: 2

Related Questions