Hi, I'm trying to use the .find(), to search for a specific DivId inside of another div. <div id="container9"><div id="box9"></div>
It sort of works, but I'm having trouble getting the code to run this when I use it in a if/else statement, it loads the entire ifelse statement, instead of just for when the if or else statements are true. Was wondering if anyone could shed some light. Shouldn't it search Container 9 for id"#box9", then execute that code, then break out of the if statement completely? The else shouldn't become true until I click it again.
http://jsfiddle.net/u8jn3/1/- $(document).ready(function(){
- $('#container9').click(function(){
- if ($('#container9').find('#box9'))
- {
- $('#box9').appendTo('#container1');
$('#box8').appendTo('#container9');
$('#box7').appendTo('#container8');
$('#box6').appendTo('#container7');
$('#box5').appendTo('#container6');
$('#box4').appendTo('#container5');
$('#box3').appendTo('#container4');
$('#box2').appendTo('#container3');
$('#box1').appendTo('#container2');
return false; - }
-
- else($('#container9').find('#box8'))
{
$('#box9').appendTo('#container2');
$('#box8').appendTo('#container1');
$('#box7').appendTo('#container9');
$('#box6').appendTo('#container8');
$('#box5').appendTo('#container7');
$('#box4').appendTo('#container6');
$('#box3').appendTo('#container5');
$('#box2').appendTo('#container4');
$('#box1').appendTo('#container3');
}
- });
- });
-