How to wrap jQuery function in a div?

Why isnt this Jquery working?

  • code is... <script type="text/javascript" src="jquery.js"></script> <script type="text/javascript"> $(function() { $('#cell1').live("mouseenter", function(){ $(function() { var $tablewrap1 = $('<div>').attr('id', 'wrapper1').attr('style', 'width: 147px; height: 76px; position: absolute; top: 292px; left: 516px;'); var $tabel1 = $('<table>').attr('id', 'subtable1').attr('bgcolor', '#33ccff'); var $cell1 = $('<td>').attr('class', 'cells').attr('id', 'subcell1').attr('onmouseover', 'style.backgroundColor="#84DFC1";' ).attr('onmouseout', 'style.backgroundColor="#666666";').appe… size="5" color="#33ccff">Cessna</font>'); $tabel1.append($('<tr>').append($cell1 , $('</td></tr>')));$tablewrap1.append($ta… }); }); $(function() { $('#cell1').live("mouseenter", function(){ $leaveoutofmaincell1 = '0'; }); $('#cell1').live("mouseleave", function(){ $leaveoutofmaincell1 = '1'; if (($leaveoutofsubcell1 = '1')) { $('div').remove('#wrapper1'); } }); $('#wrapper1').live("mouseenter", function(){ $leaveoutofsubcell1 = '0'; }); $('#wrapper1').live("mouseleave", function(){ $leaveoutofsubcell1 = '1'; if (($leaveoutofmaincell1 = '1')) { $('div').remove('#wrapper1'); } }); }); This should work! the hover works it changes color and adds the cell but I cant quite work out the close part. NO matter which way i add the if statement it fires that it is not on the new cell when i move straight from the original cell to the child cell the child cell directly overlaps the parent cell yet still when i try and move to the new cell it deletes the div. WHAT THE HECK!??!?!?!?!?

  • Answer:

    Don't know if it's the only problem, but all your if statements are wrong. You are using =, which is an assignment operator. You want to use == to test for equality. You also don't need double parens, although they don't break anything: if( $leaveoutofsubcell1 == '1') {

Allenph at Yahoo! Answers Visit the source

Was this solution helpful to you?

Related Q & A:

Just Added Q & A:

Find solution

For every problem there is a solution! Proved by Solucija.

  • Got an issue and looking for advice?

  • Ask Solucija to search every corner of the Web for help.

  • Get workable solutions and helpful tips in a moment.

Just ask Solucija about an issue you face and immediately get a list of ready solutions, answers and tips from other Internet users. We always provide the most suitable and complete answer to your question at the top, along with a few good alternatives below.