0

I have a markup like this:

<body onLoad="func();" onResize="func();" id="myId">

I was wondering how can I trigger this just through jQuery?

3 Answers 3

3
$( "body" ).on( "load resize", func );
$( "body" ).trigger( "resize" );
Sign up to request clarification or add additional context in comments.

1 Comment

This calls the function 2 times, first on load event and again on triggering the resize.
2
$(function() {
    $(window).on('resize', func);
    func();
});

Comments

1
$('body').bind('load resize', func);

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.