im stuck with a problem
im basically trying to create a function where I allocate different text (from an array) to different divs which are of the same class, these divs are differentiated by an id, here is an example of what i mean
HTML markup
<div class='actContainer'>
<div class='msgContainer'>
<input class='activityId' type='hidden' value='1'>
<div class='date'> </div>
</div>
<div class='msgContainer'>
<input class='activityId' type='hidden' value='2'>
<div class='date'> </div>
</div>
<div class='msgContainer'>
<input class='activityId' type='hidden' value='3'>
<div class='date'> </div>
</div>
</div>
JQuery code
var textArr = ['time1', 'time2', 'time3'];
var id = [1, 2, 3];
$.each(textArr, function(key, value){
$('.actContainer').find('input#activityId').val()==id[key]
.parent().find('div.date')
.append("Posted message at"+textArr[key]);
}
As you can see from the code im trying to place text between the div.date tag.
This currently doesn’t work so I must be doing something wrong, if anyone could help that would be much appreciated
You need this:
This means that you are searching for an input with the activityId class, which also has a value that is equals to id[key].
you would like to find a div near it that has a class date, and you’d like to change it’s text content to “posted message … “