What is the best easy way to randomly display inline images from a folder on every refresh or page load? using jQuery.
as the jQuery version of this http://javascript.internet.com/miscellaneous/random-image.html
Update: April 24th
This is exactly what I want, I just need an unobtrusive jQuery version of this
<div class="me-box"> <script language="JavaScript"> function banner() { } ; b = new banner() ; n = 0 b[n++]= "<img name=randimg src=’images/me.jpg’ >" b[n++]= "<img name=randimg src=’images/me2.jpg’ >" b[n++]= "<img name=randimg src=’images/me4.jpg’ >" b[n++]= "<img name=randimg src=’images/me5.jpg’ >" b[n++]= "<img name=randimg src=’images/me6.jpg’ >" b[n++]= "<img name=randimg src=’images/me3.jpg’ >" i=Math.floor(Math.random() * n) ; document.write( b[i] ) </script> </div>
I found a solution here
http://www.robwalshonline.com/posts/jquery-plugin-random-image-on-page-load/
jQuery . - , , , , 1.jpg, 2.jpg script.
, , JSON JavaScript. JSON .
$.getJSON('get/files', function(data) { $.each(data, function(image) { $('#my-div ul').append('<li><img src="' + image + '" alt="" />'); }); });
, , pics , . , , . , , .
$(document).ready(function() { var rndNumber; var displayPictures = new Array(); displayPictures[0...n] = 'filename.jpg'; rndNumber = (Math.floor(Math.random()*displayPictures.length)); $('#picture_tag_id_name').attr('src', 'images/'+displayPictures[rndNumber]); });
, PHP "" , .
, .
Source: https://habr.com/ru/post/1742398/More articles:Which .lib file starts with "! "? - c ++How to insert cgi in html - htmlHow to set parameters in jqgrid? - jqueryJFrame with multiple layers - javahow to make animation for android - androidASP.NET MVC2. Does Html.EnableClientValidation () work on a nested data model? - jquerySupport one to one object mapping - c #JQuery: How to determine if slideToggle mode has been switched? - javascriptInadvertent Concatenation in Bison / Yacc - cPhp сеансы обеспечивают безопасный вход в систему - securityAll Articles