Randomly add ID to a element with jQuery -
As you can read by title, I just want to add a random id (# one or # two or # three Or #four) .cloud element to reload the page.
HTML & lt; Div class = "cloud" & gt; & Lt; / Div & gt; CSS .cloud {/ main style for each cloud} / # Additional style of #one ########################################################################################## # # # # # # # # # # # # # # # # # # # # # # # # # # # # When trying to copy and paste code from some pages on the web Any help? & lt; Script & gt; $ (Document) .ready (function () {var id = ['one', 'two', 'three', 'four']; $ ('. Cloud') each (function (i) {$ (this) .attr (styleIIS [Math.floor (Math.Rendum (* * styleIds.length)]);});}); & Lt; / Script & gt;
Edit: Thanks to everyone! I just want to expect more useful answers like yours and less negative votes for your stupid or unclear questions: P is not so good with code I am the reason that I say your help!
Try it out:
$ (document) .ready (function () {Var id = ['one', 'two', 'three', 'four']; $ ('. Cloud'). Each (function (i) {$ (this) .attr ('id', Id [Math.floor (math.random) * id.length)]);}}}}};
Comments
Post a Comment