1st post! Question about using a jQuery path as a variable
So I have a switch statement that I dynamically assign a variable that includes a path (parent().parent().parent()... etc) that I reference later in a for loop to dynamically append an element based on this path.
But I can't figure out how to do this to make it work. I think it has something to do with my "this" usage. Also, any help that actually explains what I'm doing wrong, rather than just an answer, is greatly appreciated. I need to understand why my code doesn't work rather than just being told an answer
Here's my code thus far:
-
var sub, path;
switch(type) {
case "From" :
sub = $('.mail-inbox-from');
path = this.parent().parent().parent();
break;
}
var l = sub.length;
sub.sort(sortSubject);
for(var i=0; i<l; i++) {
$('#MailScrollContainer').append($(sub[i]).path);
}
Basically it's an email application that can be sorted via Subject, From, etc. This specific example is being sorted by "From."
Thanks for any and all help! Looking forward to many more posts on the forum! I love me some jQuery
