I have a weekly schedule that I update manually using a static table. As A Row
I need your help, if the following code below counts every …
How To Make A Transition Effect Up The Input On Change
I need to place this particular effect on a dropdown I need…
JQuery Remove Parent Elements
I have some third party HTML that looks like this: …
October 2 | 12:30 pmSolution 1:
I would suggest using an object: var compClass = {
'al' : 'alpha',
'be' : 'beta',
'ga' : 'gamma',
'de' : 'delta'
}
var k = Object.keys(compClass);
$('tr[class]').each(function() {
var prop = $.grep(this.className.split(' '), function(value) {
return k.indexOf(value) > -1;
})[0];
if (prop) this.children[2].innerHTML = compClass[prop];
});
http://jsfiddle.net/3wGmR/1/
Solution 2:
This should do the trick: $.map($("tr"), function(tr, i) {
$.each(compClass, function(index, someClass){
if ($(tr).hasClass(someClass)) {
classIndex = compClass.indexOf(someClass);
compVal = competitions[classIndex];
$(tr).find(".competition").each(function() {this.innerHTML = compVal});
};
});
});
});
http://jsfiddle.net/U7qWB/1/
| |
---|
Post a Comment for "Jquery: Using Multiple Arrays To Match Class Attribute Which Determines Childnodes Html?"