Ron Malmstead
asked on
$(allmessages).each(function (i, obj)...not iterating through all <span> elements. Only the first one.
I'm having a problem with iterating through a class in Jquery...
The $(allmessages).each(functi on (i, obj) ... is not executing for every <span> with the class of '.encryptedtext'
It hits the first message, decrypts it perfectly, but then doesn't execute the code on the next span.
I verified that the class is present on every span where the encrypted messages exist using 'inspect' feature in Chrome.
The $(allmessages).each(functi
It hits the first message, decrypts it perfectly, but then doesn't execute the code on the next span.
I verified that the class is present on every span where the encrypted messages exist using 'inspect' feature in Chrome.
function (data) {
var ServerResponse = String(data);
ServerResponse = unescape(ServerResponse);
//alert(ServerResponse);
$(".divinner").html(ServerResponse);
// $(".divinner").append(ServerResponse);
var allmessages = $('.encryptedtext');
$(allmessages).each(function (i, obj) {
//test
var encryptedtext = $(obj).html();
encryptedtext = encryptedtext.replace(' ', '+');
//alert('message recieved encrypted: ' + encryptedtext);
//alert('message unescaped: ' + unescape(encryptedtext));
//alert('channel id and key: ' + channelid + key);
var decryptmsg = decrypt(encryptedtext, channelid + key);
alert('message decrypted:' + decryptmsg.toString(CryptoJS.enc.Utf8));
var plaintxt = decryptmsg.toString(CryptoJS.enc.Utf8);
var tempobj = obj;
$(obj).html(plaintxt);
$(obj).removeClass();
$("#panel1").animate({ scrollTop: $('#panel1')[0].scrollHeight }, 2400);
});
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
find how much you have to be sure placing an alert just after : var allmessages = $('.encryptedtext');
var allmessages = $('.encryptedtext');
alert(allmessages.length);
ASKER
... These are the html contents I'm trying to iterate through. If there is another way I would love to see some ideas...
Open in new window