Tabbed Content / Posts /

How to run javascript function when a tab is selected

I'm trying to activate a javascript function when any tab is clicked by the user, but using Onclick in the <a tag doesn't seem to work.  Can you let me know how its done please.


Mike Atkinson  9 years ago   viewed: 5773    

2 Answers

For the current version of the Tab Content it seems not possible.

The advanced version of this product ( jQuery Tabs ) is equipped with an event handler for the tab selecting event. I think that will meet your requirement.
milo   9 years ago

<ul class="tabs" data-persist="true">
<li id="liTabHvezdy"><a href="#tabHvezdy" onclick="nactiStavSvetel(1)">Hvezdne nebe</a></li>
<li id="liTabSvVoda"><a href="#tabSvVoda" onclick="nactiStavSvetel(2)">Svetlo pod vodou</a></li>

<script type="text/javascript">
    var refresher1 = setInterval(nactiStavSvetel,5000);
    setInterval(function() {clearInterval(refresher1);}, 14400000);

    function nactiStavSvetel(ktere=0) {
        if (!ktere) {
            if (document.getElementById("liTabHvezdy").className  == "selected")
            else if (document.getElementById("liTabSvVoda").className  == "selected")

        if (ktere & 1) {
                        //Any commands
        if (ktere & 2) {
                        //Any commands

  4 years ago


Your name*
(Optional. Used to modify this post afterwords)
+ =  

Ask your Own Question

  • If your question is related to the topic of this post, you can post your question to this page by clicking the "Post a reply" button at left;

  • When you want to start a new page for your question: