Home > Web Front-end > JS Tutorial > jquery code to implement mouse click text effects

jquery code to implement mouse click text effects

小云云
Release: 2018-02-02 13:33:30
Original
1922 people have browsed it

Today in [Fantasy's Blog] I saw a piece of JS code for mouse click text effects that I like. This article mainly introduces an interesting jquery code for mouse click text effects. Friends who need it can refer to it. I hope it can help everyone. .

Just put the following JS code before </body>.


<script type="text/javascript">
/* 鼠标特效 */
var a_idx = 0;
jQuery(document).ready(function($) {
  $("body").click(function(e) {
    var a = new Array("富强", "民主", "文明", "和谐", "自由", "平等", "公正" ,"法治", "爱国", "敬业", "诚信", "友善");
    var $i = $("<span/>").text(a[a_idx]);
    a_idx = (a_idx + 1) % a.length;
    var x = e.pageX,
    y = e.pageY;
    $i.css({
      "z-index": 999999999999999999999999999999999999999999999999999999999999999999999,
      "top": y - 20,
      "left": x,
      "position": "absolute",
      "font-weight": "bold",
      "color": "#ff6651"
    });
    $("body").append($i);
    $i.animate({
      "top": y - 180,
      "opacity": 0
    },
    1500,
    function() {
      $i.remove();
    });
  });
});
</script>
Copy after login

I don’t know why, but the JS codes that can be used by WordPress are invalid when placed in Typecho. It’s frustrating!

This effect is generally not used by large websites, but it is generally good for personal blogs.

Related recommendations:

js How to implement Transformers text special effects code sharing

Summary of 7 typical text special effects cases

5 Cool and Practical Web Text Effects Download Recommendations (Collection)

The above is the detailed content of jquery code to implement mouse click text effects. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template