Can not get input type submit/input working with Google Chrome and jQuery
I am using jquery code to handle language translation, I have in my previous posts, gotten the code 开发者_如何学编程to handle most text and ajax translations.
And this code even works 100% in firefox, but when testing on google chrome 5.0.365.2 Dev
$("input:button,input:submit").each(function() {
var value = $(this).val();
// check if there is value
if (value != undefined) {
for (var x = 0; x < en_count; x++) {
var from = en_lang[x];
var to = toCache[x];
// if node has data translated skip it
var ist = $(this).data('translated');
if (ist != 'yes') {
if (value.match(from)) {
value = to;
$(this).attr('value',to);
}
}
}
}
});
Before this code, I create 2 array's 1 for english and 1 for an other language.
en_lng contains the array for english text on this page. toCache contains the array for the other language, that i am translating to.
To help make sure not to translate a piece of text more than once, I am using the data property, and storing the value of 'translated'.
So in the end, this code is just for translating input button/submit text.
Thank You....
I've just made a test in Firefox and it seems the if there is no value for an input it returns an empty string, not undefined. Thus it will always work in Firefox (I can't test Chrome at the moment.)
Try alerting the value of value
before the if statement.
精彩评论