0

I have the following script:

$(document).ready(function() { $('*:lang(English)').hide(); $('*:lang(French)').hide(); }); 

What I need is that every element with attribute lang="English" or lang="French" to be hidden initially.

but now when I load my website it glitches. since html starts being rendered before $(document).ready becomes well "ready". So as a consequence all elements with the above specified attribute will be shown for a split second.

Is there a way to put a handler on every *:lang(English) before document is ready so I don't see anymore glitches?

1 Answer 1

2

You should probably remove the jQuery and do this with CSS:

*:lang(en), *:lang(fr) { display: none; } 

Then, if you want to show only one language, for example, do that with jQuery.

$(document).ready(function() { $('*:lang(fr)').show(); }); 
Sign up to request clarification or add additional context in comments.

2 Comments

Fantastic, that solved it....Quick question though, what is the difference between this and using visibility property?
visibility: hidden makes it invisible, but it still takes up space. display: none is as if it were never even there, taking up no space.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.