tags:

views:

855

answers:

2

How do I add a div after each item in a checkbox list. My new div should be right after the clicked Item and before the next item in the checkbox list control in asp.NET I know that the checkbox list is rendered as a table and each item is in a tr and an input and label inside the td

table for each item ----table row ----td -----input and label

end foreach /table

I need to add a div after the label of the checked item in the checkboxlist using "jQuery". How do i find the label tag and insert the div from there on....?/

A: 

You should use appendTo.

It sounds like you're using ASP.NET CheckBoxList. So probably something like this would work (I haven't tested this):


$("table label").each(function() {
     $(this).appendTo("<div>your new div</div>");
});
mgroves
I need to add a div but appendTO is removing the td and adding the new div?.
Greens
+2  A: 

Actually, you're inserting outside, so you'll want to use after.

http://docs.jquery.com/Manipulation/after#content

$("table label").after("<div></div>");
ScottE
oh whoops, yes that's correct :)
mgroves
yep that works.......
Greens