hello all, i'm allowing users to append and remove divs at will. the divs are
numbered. if there are 5 divs and user removes div #2 i need to subtract 1
from divs #3,4,5 so that they become divs #2,3,4. 
 
here is my appending code:
$('#schematics_main').append("<div id='hotspot_" + total_hotspots + "'
class='jqDnR'><div class='rhs'>" + total_hotspots + "</div><div
class='jqHandle jqDrag'>HS "+ (total_hotspots+1) + "</div><p
class=\"removehs\">Remove</p><div class='jqHandle jqResize'></div><input
name='hotspot_" + total_hotspots + "_co' id='hotspot_" + total_hotspots +
"_co' type='text' size='25' maxlength='25' /></div>");
 
 
here is my remove code:
$('.removehs').click(function(){
        rem_this = $(this).parent().find('div.rhs').html(); // value of clicked 
div
        //$(this).parent().remove(); // remove clicked div
        for (var a=0; a<total_hotspots; a++){ // total_hotspots is a number spit
out from a database
                poop = $('#hotspot_'+a).find('div.rhs').html();
                        if(poop > rem_this){
                                
$('#hotspot_'+a).parent().find('div.rhs').html((poop-1)); //it works
just find a way to subtract 1 from the existing value!!
                        }       
        alert(a);
        }
});
 
the problem is the for loop. my expectations for the loop is that it grabs
the value of the clicked div, and then loops through all divs checking to
see if each div is greater or smaller than the clicked div's value. if
greater, subtract 1 from that value.
 
so, my point?
problem 1: the code doesn't do any subtraction but i can alert all div info
(id's, values, etc) correctly
problem 2: if i've appended 2 new divs the for loop will run twice, if 3
divs appended it runs 3 times. i know it has something to do with the fact
that all divs have a .removehs class.
 
thanks in advance,
Kelly
-- 
View this message in context: 
http://www.nabble.com/can%27t-change-values-in-appended-divs-tp19680077s27240p19680077.html
Sent from the jQuery General Discussion mailing list archive at Nabble.com.

Reply via email to