2

I want to put a switch for my website that when you click it the language of the page change. Yesterday I saw a close live example in a website.

Here's the link: http://iranfilm76.com/

The object on the left side in the header is exactly what I'm trying to achieve, but instead of changing the background i want to change the language.

I already have the functions for changing the language, my problem is the object, I download the image and css for the file.

I take a close look at the codes with firebug and when you click on the tag the class of the tag changes to class="changestyle".

How can I do this? Thanks for any suggestion.

4

2 に答える 2

3
YOUR_ELEMENT.addEventListener("click", function(){
    this.classList.toggle("changestyle");
});

デモ: http://jsfiddle.net/DerekL/KpwkG/ | http://jsfiddle.net/WsGGa

于 2013-07-24T05:32:35.650 に答える
1

非純粋な JavaScript アプローチの場合、次のように jquery を使用してトグル要素を選択してみてください。

$('element').click(function(){
     $(this).toggleClass('language');
});

次に、CSSで、必要なルールを適用できます

于 2013-07-24T05:34:10.307 に答える