Where are you doing the hookup? If it's in a script tag above the actual "container" div and you don't have it wrapped in some kind of ready callback or similar, that might be the problem. Or if you're adding children to the div afterward (since you're using click, which hooks up the handler only to the children there right then).
Because if the "container" div and its children already exist, your code works:
HTML:
<div id='container'>
<div>Child 1</div>
<div>Child 2</div>
<div>Child 3</div>
</div>
<input type='button' id='btnAdd' value='Add a new child'>
JavaScript:
$('#btnAdd').click(function() {
$("#container").append("<div>New child, clicking me <em>won't</em> work</div>");
});
$('#container').children().click(function(){
divClicked($(this));
});
function divClicked(selectedDiv)
{
// You don't want `$` here, but I've left it just to demonstrate
// that your code should, largely, be working
$(selectedDiv).css('background', 'red');
}
Live copy
...but note that elements added afterward don't work, because they weren't there when you hooked things up.
Fixing it will depend on what's wrong. It could just be wrapping your hook-up code in a ready handler (as I have in that example) or moving it to code in a script tag at the bottom of your page, just before the closing </body> tag (as the YUI folks recommend), or perhaps using live or delegate.
delegateif I understand your question correctly. currentlythisdoes not refer to#containerthisrefer to the div clicked... I think he got it right no?csscall isn't working. Should be easy enough to figure out which by walking through the code.