Blah
I want to set $(\'#
<script>
var test = $('#example #test').length();
if(test !== 0){
$('#another').hide();
}
</script>
Use length
if ($('#example').find('#test').length) {
// found!
}
it's pretty simple.
$(document).ready(function(){
if($('#example').children('#test').length > 0)
{
$('#another').hide();
}
});
http://jsfiddle.net/8rrTp/
jQuery manual suggests to use:
if ($('#parent').has('#child').length) {
//do something
}
http://api.jquery.com/has/
I think what you are looking for is the following
if (jQuery.contains($('#example'), $('#test')) {
$('#another').hide();
}
This might work as well, not sure off the top of my head.
if ($('#test', $('#example')).size() > 0) {
$('#another').hide();
}