ahmet
ahmet

Reputation: 5005

default view on a <div>? without onclick

I have an onclick

onclick=\"showOrderParcelsResultsTable();\"

but in html is there a way to give some kind of default view

beacause i need it too show

showParcelResultsTable();

by default, can i do default=\"showParcelResultsTable();\" ?? but keeping the onclick at the same time

Upvotes: 0

Views: 97

Answers (2)

Dany Y
Dany Y

Reputation: 7031

onClick happens only when you click on the div. If what you want is to call showOrderParcelsResultsTable() at first before any action, you should implement in javascript

window.onload = function(){
        showParcelResultsTable();
    };

(if this function is specific to one item you can use document.getElementById(divId) and pass it as a parameter to this function, or if you're using jquery

$('#divId or .divClass').each(function(){
            showParcelResultsTable();
        };) )

Upvotes: 2

Jivings
Jivings

Reputation: 23260

Put showParcelResultsTable(); in Script tags. Either after the page element or at the top in a ready block.

At the bottom of the page:

...
<script type="text/javascript">
    showParcelResultsTable();
</script>
</html>

At the top:

<script type="text/javascript">
    window.onload = function(){
        showParcelResultsTable();
    };
</script>

Upvotes: 1

Related Questions