If you want to draw attention from some parts of your blog page, you can shake these parts, such as advertisements. Today, this article will introduce how to shake the elements on your page, if you are interested in jqueryui, do not miss it. It may be helpful for you to learn jqueryui. If you want some part of your blog page to attract the attention of readers, you can shake these parts, for example, advertisement. This article will introduce how to shake the elements on your page.
To achieve this goal, we need to use Jquery and Jquery UI.
First, let me create a vibration block, which can be an image or a common dom element, such as p and span. Name the element id as shake, which can be any name here.
We use the following picture:
The Code is as follows:
Jquery UI has no ready-made method to shake elements. We need to use the effect method. The syntax is as follows:
The Code is as follows:
Effect ('shake ', options, speed );
Parameter options (three parameters are provided here ):
• Times: specifies the number of element vibrations
• Distance: Specifies the vibration amplitude of an element.
• Direction: Specifies the direction of element vibration.
The specific implementation method is as follows:
The Code is as follows:
Function interval (){
$ ('# Shake'). effect ('shake ', {times: 3}, 100 );
}
$ (Document). ready (function (){
Var shake = setInterval (interval, 500 );
});