Hello I'm trying something .. I was reading Jquery traversing documentations some forums, this websites previously asked questions relating this topic .. none actually answers my question so I'll ask instead .. here is the deal
<div class="entry">
week
<span>some text</span>
<p>DKK</p>
<input type="radio" name="red<% Response.Write(counter); %>" id="radio2" value="75" />
</div>
So I've used a while loop to create bunch of these so I don't have to manually copy paste them.. asp generates them .. now you see the p section it says DKK .. now in order for me not to write everything manually I'd like every divs , p to append with the value of input inside that div , now here is what I did with Jquery
$(document).ready(function() {
$("input").each(function () {
var element_value = $(this).val();
$(this).closest("p").append(element_value + ",-");
});
});
So what I tried to do is to go trough each input and collect their value, then find closest p tag and append it with its value, now the correct result for this example above would be
<p>DKK 75,-<p>
because input value is 75 and it has included in append function ,- add that as well, this code is not working, however if I put
$(this).parents("div.entry").append(element_value + ",-");
instead of
$(this).closest("p").append(element_value + ",-");
The correct results appear but not exactly where I want them .. hopefully someone can help me, thank you