change a jquery line to play automatically, instead of on click

Viewed 14

I'm trying to make a simple animation auto play on website load. At the moment the code is set to play if I click on the element. I'd like it to simply animate.

The code is:

  <script>
    $(document).on('ready', function () {
      $('h1, h3, p, img').click(function (e) {
        $(e.target).script();

      })
    })
  </script>

So there is an image that will be doing the animating, so everything is controlled on that .click(function (e)) bit. Any ideas how to easily make it play automatically?

Thanks in advance.

1 Answers

To make it animate on the initial page load, change this line

$('h1, h3, p, img').click(function (e) {

to this:

$('h1, h3, p, img').load(function (e) {

Also, you may consider using onchange(), it may also be a good fit for what you are trying to achieve.

Related