jQuery code on a page

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Grego
    Mini Mivite

    • Apr 2014
    • 24

    #1

    jQuery code on a page

    I want to use a jQuery switch to add a class depending on a variable.

    Is it as easy as just adding it like this:

    This is how I would do it in php environment:

    ( jQuery is called in the header )

    Code:
    <script type[COLOR=#339933]=[/COLOR][COLOR=#3366CC]"text/javascript"[/COLOR]>
    
    var jsLang = 'jquery';
    
    switch (jsLang) {
        case 'jquery':
            alert('jQuery Wins!');
            break;
        case 'prototype':
            alert('prototype Wins!');
            break;
        case 'mootools':
            alert('mootools Wins!');
            break;     
        case 'dojo':
            alert('dojo Wins!');
            break;
        default:
            alert('Nobody Wins!');
    }
    //outputs "jQuery Wins!"
    
    </script>
    Can I call it in a js function?
  • Brennan
    Super Moderator









    • Jun 2009
    • 3481

    #2
    Re: jQuery code on a page

    That code should work just fine. You can put JavaScript anywhere in Miva's page templates and it will execute since it is front-end code. The Miva engine ignores it and your browser will parse it and execute it.
    Brennan Heyde
    VP Product
    Miva, Inc.
    [email protected]
    https://www.miva.com

    Comment

    Working...
    X