In my html page, I wrote:
$('div > input').click(function(){
alert(1);
});
my div is like this:
<div id="CPE202" class="course">
<input type="checkbox" name="core" value="core" />
Microprocessor programming
<input type="radio" name="remove" value="remove" class="remove"/>
</div>
then it couldn't work when this page runs. The purpose of these code is to try to alert 1 whenever the radio button is clicked. What odd is, when I debug using Firebug, I typed exactly the same as the function above, and it works. What's wrong here?
Thank you.
[edit] What I have mentioned here is already in its correct place, meaning inside $(document)....
I have also tried this:
$('div input').click(function(){
alert(1);
});
and this:
$('input:radio').click(function(){
alert(1);
});
They both don't work. It seems like any complex selector I am using here is no use somehow :(
Sorry for the confusion I have made here. I have try
$('div > input').css({ border: '1px solid red' });
but it doesn't work also.
1 more info is the <div id=...>
is DYNAMICALLY created by another piece of Jquery code. I am wondering if it is the cause for that.