Wednesday, September 9, 2015

Anchor tag Click Event on Page Load

Here is a snippet code sample for click event on DOM Load. There are times when, map <div>'s content text visibility is coded to synchronize with a user's click event. JavaScript code does execution of the code so beautifully, that so often a page loads with a DOM's  <div> space empty waiting for user events.

Not so, with Jquery's trigger event framework. Try your hands on the following code to have a program to automatically trigger a click event on your first anchor tag. The page loads in with your intended anchor tag by default and of course avoid having to present empty <div> space.

<script>
    $(document).ready(function(){
        $('The ID/Class name of the intended a href tag').trigger('click');
    });
</script>



No comments: