Function not working

Hey,

Im not sure why this isnt working, when I click the button the function doesnt seem to get called…


$(document).ready(function(){	

	$('.vwidget').children('a').click(function(){
		var a = $(this).attr("id");		
		if(a == 1)
		var container = 'upcount';
		else
		var container = 'downcount';
		
		$.post("rating.php?value="+a, {
		}, function(response){
			//$('.upcount').fadeOut();
			$('.'+container).html(unescape(response));
			$('.'+container).fadeIn();	
		});
	});	
	
	$('#diggs0').click(function(){
	
		$.post("rating.php?v=1", {
		}, function(response){
			$('#diggs-strong').html(unescape(response));
			$('#diggs-strong').fadeIn();	
		});
	});	
});	


<div style="float:left;">
			<div class="digg-count">
			<a  href="#" ><strong id="diggs-strong" style="opacity: 100;"><?php echo $row3['rating']?></strong><br /> diggs</a>
			</div>
			<div id="diggit"><a href="#" id="diggs0">diggs</a></div>
		</div>

It’s probably because of your use of the children method.

children() only goes one level deep. You probably want to use find(), or just $(‘.vwidget a’).

If that’s not the problem, you need to do a bit of debugging. Find out where exactly the failure is happening. Example:

$(document).ready(function(){   
 
    $('.vwidget').children('a').click(function(){
        alert('click!'); // something's been clicked!
        var a = $(this).attr("id");
        alert(a); // check for the ID  
        if(a == 1)
        var container = 'upcount';
        else
        var container = 'downcount';
       
        $.post("rating.php?value="+a, {
        }, function(response){
            alert(response); // check for result of ajax request
            //$('.upcount').fadeOut();
            $('.'+container).html(unescape(response));
            $('.'+container).fadeIn(); 
        });
    }); 
   
    $('#diggs0').click(function(){
   
        $.post("rating.php?v=1", {
        }, function(response){
            $('#diggs-strong').html(unescape(response));
            $('#diggs-strong').fadeIn();   
        });
    }); 
});