问题
I use jQuery.translate, very normal code as:
$('body').translate(...
Now I do not want the textarea
and input:text
get translated, so I tried:
$('*:not(textarea,:text)').translate(..
$('body *:not(textarea, input:text)').translate(
None working.
(these answers got from another question: jQuery, Select Body but exclude Textarea and Input:Text, how?
Anyone here, has an idea how to translate the body but exclude textarea and input:text, thanks.
回答1:
From the jQuery.translate wiki; first add the notranslate class to the elements you don't want to translate.
$('textarea').addClass('notranslate');
$('input:text').addClass('notranslate');
$('body').translate(...);
回答2:
A nice way to exclude elements from a selector is to use the .not method:
$('*', document.body).not('textarea, input[type=text]').translate(...);
回答3:
Does this work?
$('body').translate( 'es', 'en', { not: 'textarea, input:text' });
(This is translating from Spanish to English, of course.)
来源:https://stackoverflow.com/questions/8631134/do-not-translate-textarea-by-jquery-translator-how