Question : Find function skips duplicates

Hi,

I have a div like this:

1:
 <div id="hintdata"><div class='10003137'>Key Skills Level 3</div><div class='10003162'>Key Skills Level 3</div><div class='10003198'>Key Skills Level 3</div><div class='10030463'>Hairdressing</div><div class='10030475'>Hairdressing</div><div class='10038310'>Key Skills Level 3</div><div class='10038358'>Key Skills Level 3</div><div class='10038395'>Key Skills Level 3</div><div class='10058722'>Food level 2</div><div class='10064588'>Additional Maths</div><div class='10064588'>Additional Maths test100510</div><div class='50018048'>Welsh bacc Level 3</div><div class='50018073'>Art and Design</div><div class='50018097'>Art and Design</div><div class='50018103'>Art and Design</div><div class='50020481'>Food level 2</div><div class='50036725'>Travel and Tourism Year 12</div><div class='50036725'>Travel and Tourism Year 13</div><div class='50042555'>History of Art</div><div class='50067540'>Food Level 1</div></div></div>


and when I run this in firebug: $('#hintdata').find('div').each(function(index,element){
console.log($(element).text());
})

it does not return the div's with the same number.:

1:
[div.10003137, div.10003162, div.10003198, div.10030463, div.10030475, div.10038310, div.10038358, div.10038395, div.10058722, div.50018048, div.50018073, div.50018097, div.50018103, div.50020481, div.50042555, div.50067540]



I would like to aggregate each div so that for example :

1:
2:
3:
4:
5:
<div class='10064588'>Additional Maths</div> <div class='10064588'>Additional Maths test100510</div>

is edited to:
[code]
<div class='10064588'>Additional Maths<br />Additional Maths test100510</div> 

How would this be done?

Darren

Answer : Find function skips duplicates

Check this :

1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
<script language="javascript" src="http://code.jquery.com/jquery-1.4.2.min.js"></script>
<script language="javascript">
	$(document).ready(function() {
		var classes = [];
		$("div","#hintdata").each(function() {
			var c = $(this).attr("className");
			if(classes[c]) {
				$("div."+c).append("<br />"+ $(this).html());
				$(this).remove();
			}
			else {
				classes[c] = true;
			}
		});
                // checking
		//alert( $(".10064586").html() );
	});
</script>
</head>
<body>
<div id="hintdata">
<div class='10064588'>Additional Maths1</div><div class='10064588'>Additional Maths1 test1</div>
<div class='10064587'>Additional Maths2</div><div class='10064587'>Additional Maths2 test2</div>
<div class='10064586'>Additional Maths3</div><div class='10064586'>Additional Maths3 test3</div>
<div class='10064585'>Additional Maths4</div><div class='10064585'>Additional Maths4 test4</div>
<div class='10064584'>Additional Maths5</div><div class='10064584'>Additional Maths5 test5</div>
</div>
</body>
</html>
Random Solutions  
 
programming4us programming4us