Forums

The forums ran from 2008-2020 and are now closed and viewable here as an archive.

Home Forums JavaScript Convert JQuery function to pure JS?

  • This topic is empty.
Viewing 15 posts - 1 through 15 (of 23 total)
  • Author
    Posts
  • #190505
    codemasters
    Participant

    how do u get a random number an apply as a background on load to the body

    http://stackoverflow.com/questions/1527803/generating-random-numbers-in-javascript-in-a-specific-range

    found this link how do u do it

    #190507
    Paulie_D
    Member

    It’s not clear what you are asking for.

    A ‘number’ can’t be a background.

    What are you trying to do?

    #190509
    codemasters
    Participant

    var colors = [‘red’, ‘green’, ‘blue’, ‘orange’, ‘yellow’]

    need to something like this in javascript

    http://jsfiddle.net/voawn7nc/

    #190510
    codemasters
    Participant

    so like when u refresh the page there is a new background color

    #190511
    Paulie_D
    Member

    It’s still not clear.

    Are you saying that you want the JQuery function as pure JS?

    #190512
    codemasters
    Participant

    i 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

    #190513
    Paulie_D
    Member

    OK, 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.

    #190514
    codemasters
    Participant

    i 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

    #190515
    Ilan Firsov
    Participant

    Here (check JS tab)
    http://codepen.io/ilanf/pen/XJXLYy

    just 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

    #190516
    Paulie_D
    Member

    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

    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.

    #190607
    codemasters
    Participant

    thanks 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

    http://jsfiddle.net/codemasters14/h418csqk/

    #190608
    Paulie_D
    Member

    I 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.

    #190724
    codemasters
    Participant

    what 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
    maven

    #190727
    Paulie_D
    Member

    That’s a very broad question. One that’s not really suited to a forum such as this.

    #190853
    codemasters
    Participant

    guys 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

Viewing 15 posts - 1 through 15 (of 23 total)
  • The forum ‘JavaScript’ is closed to new topics and replies.