Home › Forums › JavaScript › Convert JQuery function to pure JS?
- This topic is empty.
-
AuthorPosts
-
December 10, 2014 at 5:38 am #190505codemastersParticipant
how do u get a random number an apply as a background on load to the body
found this link how do u do it
December 10, 2014 at 5:41 am #190507Paulie_DMemberIt’s not clear what you are asking for.
A ‘number’ can’t be a background.
What are you trying to do?
December 10, 2014 at 5:44 am #190509codemastersParticipantvar colors = [‘red’, ‘green’, ‘blue’, ‘orange’, ‘yellow’]
need to something like this in javascript
December 10, 2014 at 5:45 am #190510codemastersParticipantso like when u refresh the page there is a new background color
December 10, 2014 at 5:45 am #190511Paulie_DMemberIt’s still not clear.
Are you saying that you want the JQuery function as pure JS?
December 10, 2014 at 5:51 am #190512codemastersParticipanti want the same function but in raw javascript so when i refesh the page a different background will load just like wat happens in the fiddle link i sent Paulie
December 10, 2014 at 5:53 am #190513Paulie_DMemberOK, that’s the language barrier hurdled…now that we know what you actually want, I’ve changed the title so perhaps a JS expert can assist you.
December 10, 2014 at 5:53 am #190514codemastersParticipanti found a link on stack where in u can generate a random number id didn’t know how to implement it . Can you help paulie
December 10, 2014 at 6:13 am #190515Ilan FirsovParticipantHere (check JS tab)
http://codepen.io/ilanf/pen/XJXLYyjust make sure to put it right before the closing
</body>
**I tried to write it inside code tags here but got blocked by the firewall. apparently this little JS script is an SQL injection attack :P
December 10, 2014 at 6:25 am #190516Paulie_DMemberI tried to write it inside code tags here but got blocked by the firewall. apparently this little JS script is an SQL injection attack
This site is very sensitive to any JS that escapes the code ticks so it tends to reject it.
Codepen is always your best bet.
December 11, 2014 at 8:45 am #190607codemastersParticipantthanks paulie an Ilan Firsov but what if i have to add different colors to the li on load but the bg color should be different so like how do i archive that an thanks to i got to learn how Math.floor works this site really helps in learning an the people here too can u please help me on the below thing
December 11, 2014 at 9:00 am #190608Paulie_DMemberI think you’re doing this piecemeal instead of telling us what the concept is and asking the best solution.
At the moment, you’re running 5 different functions ( I think) instead of one same function 5 times.
December 13, 2014 at 6:23 am #190724codemastersParticipantwhat would be the best way of doing it since i don’t have experience in js just a beginner paulie_d if u could help if would be great
regards
mavenDecember 13, 2014 at 8:56 am #190727Paulie_DMemberThat’s a very broad question. One that’s not really suited to a forum such as this.
December 15, 2014 at 8:50 am #190853codemastersParticipantguys i have been told to implement on a unit now i have a ul li on refresh of the page the background color of the li should change i have 5 list items so when i refresh the page the 5 listed items should have different backgrounds so like i don’t get a repeated background
-
AuthorPosts
- The forum ‘JavaScript’ is closed to new topics and replies.