# rotate

In an earlier lesson you were introduced to jqRotate.js, the add-on function that allows you to rotate elements in an html page. In the previous lesson, rotation was activated by mouse clicks. It is also possible to use the setInterval function to create a timed rotation, so that the rotation event re-occurs based on milliseconds. Why? With this function you can start a rotation that doesn't stop, such as a record player or the tires on a car.

The setInterval function is extremely to use In the example immediately below any action that you place between the { } brackets, will be executed every 2000 milliseconds (which is the same as every 2 seconds).

```setInterval(function() {
// Do something every 2 seconds
}, 2000);```

### Jquery Rotation example with the jqrotate library

In the following setInterval function, a variable named howfar, that increments +5 (as in 5, 10, 15, etc.) every 800 milliseconds, controls the rotation of an element with the class "munk."  The same setInterval function can also be used to move elements in a straight or diagonal line by incrementing the x and/or y  values. By the way, the rotation shown below relies on the jqrotate library.

```var howfar = 0;
setInterval(function(){
howfar+=5;
\$(".munk").rotate(howfar);},800);```

### Pure Javascript example with .transform

``` var spinner = document.querySelector('#spinner');
var howfar = 0;
setInterval(function(){ howfar+=1;
spinner.style.transform = "rotate("+howfar+"deg)"; },8);```
{"ft_lang_label":"__label__en","ft_lang_prob":0.82616484,"math_prob":0.9137368,"size":1451,"snap":"2020-34-2020-40","text_gpt3_token_len":326,"char_repetition_ratio":0.15825847,"word_repetition_ratio":0.009090909,"special_character_ratio":0.2432805,"punctuation_ratio":0.1521739,"nsfw_num_words":0,"has_unicode_error":false,"math_prob_llama3":0.95492953,"pos_list":[0],"im_url_duplicate_count":[null],"WARC_HEADER":"{\"WARC-Type\":\"response\",\"WARC-Date\":\"2020-08-09T10:58:28Z\",\"WARC-Record-ID\":\"<urn:uuid:9a23785e-cd9a-42dd-95b4-822cfdef3ed1>\",\"Content-Length\":\"33379\",\"Content-Type\":\"application/http; msgtype=response\",\"WARC-Warcinfo-ID\":\"<urn:uuid:53a3a658-3c0f-45d2-aed6-90fa48c63721>\",\"WARC-Concurrent-To\":\"<urn:uuid:5a318955-1a21-42a9-9bee-13f902a2a6c4>\",\"WARC-IP-Address\":\"192.254.154.65\",\"WARC-Target-URI\":\"http://workbook.mynmi.net/rotate/\",\"WARC-Payload-Digest\":\"sha1:FE6RJOJV5FVQS7CWUUPGERWREUUQOSWY\",\"WARC-Block-Digest\":\"sha1:XNXBL453PWDYGW5UTXW5IGWH6GUP22CQ\",\"WARC-Identified-Payload-Type\":\"text/html\",\"warc_filename\":\"/cc_download/warc_2020/CC-MAIN-2020-34/CC-MAIN-2020-34_segments_1596439738552.17_warc_CC-MAIN-20200809102845-20200809132845-00407.warc.gz\"}"}