Tabbed Content / Posts /

How to run javascript function when a tab is selected

0
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

Mike Atkinson  11 years ago   viewed: 6974    

2 Answers

0
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   11 years ago
0

<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>
</ul>

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

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

        if (ktere & 1) {
                        //Any commands
        };
        if (ktere & 2) {
                        //Any commands
        };
    };
</script>

JirkaN
  6 years ago

   

Your name*
Password
(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: