Please help me make wordpress on my site ( https://giffs.ru ), so that the gifs would be launched by clicking or hovering, I myself am not new to scripts yet, and all the GIF Animation Preview and WP GIF Player plugins do not work, already week I fight. Ideally, I would like something like http://fishki.net/auto/2413484-podborka-avtomobilynyh-gifok.html like this!
2 answers
Well, for example, like this
jQuery(document).ready(function($) { $("img").hover(function() { var src = this.src; this.src = $(this).data("img"); $(this).data("img", src); }); }); <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script> <img src="https://yt3.ggpht.com/-DBNBnMLsnrs/AAAAAAAAAAI/AAAAAAAAAAA/onFqjfb9JQs/s100-ck-no-mo-rj-c0xffffff/photo.jpg" data-img="http://liubavyshka.ru/_ph/177/2/403146738.gif"/> <img src="https://yt3.ggpht.com/-A58yPmvdnIc/AAAAAAAAAAI/AAAAAAAAAAA/2o1tCSQHEG0/s100-ck-no-mo-rj-c0xffffff/photo.jpg" data-img="http://lizasimpson.com/uploads/_pages/613/simpsons-avatars-2.gif"/> <img src="https://yt3.ggpht.com/-sEESfUOW2IM/AAAAAAAAAAI/AAAAAAAAAAA/7E_dHNhe9wI/s100-ck-no-mo-rj-c0xffffff/photo.jpg" data-img="https://vignette.wikia.nocookie.net/uncyclopedia/images/1/17/Simpsons-1.gif/revision/latest?cb=20081006234733"/> On the hit / runaway of the mouse we swap the values ββof the attributes src and data-img
- I understand correctly that this code should be added to functions.php and after that such an insert should have such an effect? - Eugene
- @ Eugene unfortunately is not familiar with WordPress. Try it - Anton Shchyrov
|
First show a non-animated picture and replace it with a gif.
- Well, I understand that, but Iβm saying that Iβm a beginner, how can I explain in more detail how to implement it? And I understand the scheme .... - Eugene
- The published message does not contain a solution. When your reputation reaches the required level, you can leave comments on any message ; for now, please make an improvement in your post so that it will answer the question without further clarification from the author . - From the queue of checks - aleksandr barakin
- @alexanderbarakin, in principle, is the answer. - Qwertiy β¦
|
//ΠΏΠ΅ΡΠ²ΠΎΠ½Π°ΡΠ°Π»ΡΠ½ΠΎ ΠΏΠΎΠΊΠ°Π·ΡΠ²Π°Π΅ΡΠ΅ ΡΡΠ°ΡΠΈΡΠ΅ΡΠΊΡΡ ΠΊΠ°ΡΡΠΈΠ½ΠΊΡ, Π° Π½Π΅ gif // Π±Π΅ΡΠ΅ΠΌ ΠΎΡΠ½ΠΎΠ²Π½ΠΎΠΉ Π±Π»ΠΎΠΊ Ρ ΠΊΠ°ΡΡΠΈΠ½ΠΊΠ°ΠΌΠΈ var div = document.getElementById("div"); //ΠΎΡΡΠ»Π΅ΠΆΠΈΠ²Π°Π΅ΠΌ ΠΊΠ»ΠΈΠΊ ΠΏΠΎ ΠΊΠ°ΡΡΠΈΠ½ΠΊΠ΅ div.onclick = function(event){ var target = event.target; //Π·Π°ΠΌΠ΅Π½ΡΠ΅ΠΌ ΠΊΠ°ΡΡΠΈΠ½ΠΊΡ Π½Π° Π³ΠΈΡΠΊΡ target.src = "ΠΏΡΡΡ ΠΊ Π³ΠΈΡΠΊΠ΅"; };I see it like this - Dmytryk