Ad

Change Page And Then Change A Class

- 1 answer

Is it possible to change a Class (by ID) after clicking a link that jumps to that page? I've page 01, and when I click a link in Page 01, I want it to jump to Page 02 and then change a Class in Page 02. Is it possible?

Ad

Answer

Actually, the post that was deleted helped me a lot :)

I used this code to get the parameter

            function getParam( name ){
            name = name.replace(/[\[]/,"\\\[").replace(/[\]]/,"\\\]");
            var regexS = "[\\?&]"+name+"=([^&#]*)";
            var regex = new RegExp( regexS );
            var results = regex.exec( window.location.href );
            if( results == null )
                return "";
                else
                return results[1];
        }

Then removed the Class and added a new one

        var idPassing = getParam( 'id' );

        if(idPassing == "Publicidade"){
            functRemoveClassCurrent();
            document.getElementById("idFilterPublicidade").className+="current";
        }

Thank you all!!!

Ad
source: stackoverflow.com
Ad