Update a div if the id was clicked using jquery
<p>Please I am currently building a football betting processor and am stuck. Please help me out in editing it.
    I want the code to check if a div id is active,and if active, update div with clicked data and return false.
    Thanks in advance.</p>

<pre><code>&lt;table class="bets-selection-table"&gt;&lt;tr&gt;
&lt;td style="padding-left: 2px; text-align:center"&gt;&lt;select id="oddsByTypeDropDown" name="oddsByTypeDropDown" class="odds-by" size="1"&gt;    &lt;option selected="selected" value="1X2"&gt;1X2&lt;/option&gt;
&lt;option value="Handicap (1X2)"&gt;Handicap (1X2)&lt;/option&gt;
&lt;option value="1st half result"&gt;1st half result&lt;/option&gt;
&lt;option value="Double Chance"&gt;Double Chance&lt;/option&gt;
&lt;option value="Halftime/Fulltime"&gt;Halftime/Fulltime&lt;/option&gt;
&lt;option value="1 2"&gt;1 2&lt;/option&gt;
&lt;option value="Under/Over"&gt;Under/Over&lt;/option&gt;
&lt;option value="Correct score"&gt;Correct score&lt;/option&gt;
&lt;option value="Total goals (odd/even)"&gt;Total goals (odd/even)&lt;/option&gt;
&lt;option value="To score first goal"&gt;To score first goal&lt;/option&gt;
&lt;option value="Draw no bet"&gt;Draw no bet&lt;/option&gt;
&lt;option value="Both teams to score"&gt;Both teams to score&lt;/option&gt;
&lt;option value="Total goals (home team)"&gt;Total goals (home team)&lt;/option&gt;
&lt;option value="Total goals (away team)"&gt;Total goals (away team)&lt;/option&gt;
  &lt;/select&gt;&lt;/td&gt;
&lt;td style="padding-left: 2px;"&gt;&lt;input id="showByTypeButton" onClick="showBetsOnType();" style="width: 55px;" class="signUp_button" value="Show" type="button"&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/table&gt;

&lt;table id="lelct" style="padding:10px;" cellpadding="0" cellspacing="0"&gt;
&lt;tr class="bestBets_row"&gt;
&lt;td class="bestBets_category_outcome1" id="rgExp_432"&gt;&lt;div class="main_class outcome_odds"&gt;&lt;div class="news_hm_ldiv" id="home_432"&gt;India&lt;/div&gt;&lt;div class="news_hm_rdiv" id="hodd_432"&gt;5.2&lt;/div&gt;&lt;/div&gt;&lt;/td&gt;&lt;td class="space"&gt;&lt;/td&gt;

&lt;td class="bestBets_category_outcome2" id="rgExp_432"&gt;&lt;div class="main_class outcome_odds"&gt;&lt;div class="news_hm_ldiv"&gt;Draw&lt;/div&gt;&lt;div class="news_hm_rdiv" id="draw_432"&gt;3.2&lt;/div&gt;&lt;/div&gt;&lt;/td&gt;&lt;td class="space"&gt;&lt;/td&gt;

&lt;td class="bestBets_category_outcome3" id="rgExp_432"&gt;&lt;div class="main_class outcome_odds"&gt;&lt;div class="news_hm_ldiv" id="away_432"&gt;Nigeria&lt;/div&gt;&lt;div class="news_hm_rdiv" id="aodd_432"&gt;4.6&lt;/div&gt;&lt;/div&gt;&lt;/td&gt;&lt;td class="space"&gt;&lt;/td&gt;&lt;td class="bestBets_c9"&gt;&lt;div onclick="goToPage('handicap.php?id=432')" class="bestBets_moreGames" style="cursor:pointer;"&gt;++&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;

&lt;tr class="bestBets_row"&gt;
&lt;td class="bestBets_category_outcome1" id="rgExp_433"&gt;&lt;div class="main_class outcome_odds"&gt;&lt;div class="news_hm_ldiv" id="home_433"&gt;U.S.A&lt;/div&gt;&lt;div class="news_hm_rdiv" id="hodd_433"&gt;5.0&lt;/div&gt;&lt;/div&gt;&lt;/td&gt;&lt;td class="space"&gt;&lt;/td&gt;

&lt;td class="bestBets_category_outcome2" id="rgExp_433"&gt;&lt;div class="main_class outcome_odds"&gt;&lt;div class="news_hm_ldiv"&gt;Draw&lt;/div&gt;&lt;div class="news_hm_rdiv" id="draw_433"&gt;1.2&lt;/div&gt;&lt;/div&gt;&lt;/td&gt;&lt;td class="space"&gt;&lt;/td&gt;

&lt;td class="bestBets_category_outcome3" id="rgExp_433"&gt;&lt;div class="main_class outcome_odds"&gt;&lt;div class="news_hm_ldiv" id="away_433"&gt;Uganda&lt;/div&gt;&lt;div class="news_hm_rdiv" id="aodd_433"&gt;1.6&lt;/div&gt;&lt;/div&gt;&lt;/td&gt;&lt;td class="space"&gt;&lt;/td&gt;&lt;td class="bestBets_c9"&gt;&lt;div onclick="goToPage('handicap.php?id=433')" class="bestBets_moreGames" style="cursor:pointer;"&gt;++&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;

&lt;tr class="bestBets_row"&gt;
&lt;td class="bestBets_category_outcome1" id="rgExp_434"&gt;&lt;div class="main_class outcome_odds"&gt;&lt;div class="news_hm_ldiv" id="home_434"&gt;Spain&lt;/div&gt;&lt;div class="news_hm_rdiv" id="hodd_434"&gt;3.2&lt;/div&gt;&lt;/div&gt;&lt;/td&gt;&lt;td class="space"&gt;&lt;/td&gt;

&lt;td class="bestBets_category_outcome2" id="rgExp_434"&gt;&lt;div class="main_class outcome_odds"&gt;&lt;div class="news_hm_ldiv"&gt;Draw&lt;/div&gt;&lt;div class="news_hm_rdiv" id="draw_434"&gt;3.7&lt;/div&gt;&lt;/div&gt;&lt;/td&gt;&lt;td class="space"&gt;&lt;/td&gt;

&lt;td class="bestBets_category_outcome3" id="rgExp_434"&gt;&lt;div class="main_class outcome_odds"&gt;&lt;div class="news_hm_ldiv" id="away_434"&gt;Paraguy&lt;/div&gt;&lt;div class="news_hm_rdiv" id="aodd_434"&gt;2.6&lt;/div&gt;&lt;/div&gt;&lt;/td&gt;&lt;td class="space"&gt;&lt;/td&gt;&lt;td class="bestBets_c9"&gt;&lt;div onclick="goToPage('handicap.php?id=434')" class="bestBets_moreGames" style="cursor:pointer;"&gt;++&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;

&lt;/table&gt;

&lt;div id="first-right"&gt;
&lt;table id="lasvegas"&gt;

&lt;/table&gt;
&lt;div id="selar"&gt;
&lt;table style="background-color:#EDEDED;"&gt;
&lt;tr&gt;&lt;td width="200"&gt;Odds:&lt;/td&gt;&lt;td id="odds"&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;
&lt;table&gt;
&lt;tr&gt;&lt;td width="205"&gt;Stake:&lt;/td&gt;&lt;td&gt;&lt;input type="number" onkeyup="addUp()" maxlength="4" style="background-color:#999; color:#FC6; text-align:right;" size="5" name="stake" id="stake" /&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/table&gt;
&lt;table style="background-color:#EDEDED;"&gt;
&lt;tr&gt;&lt;td width="200"&gt;Winning:&lt;/td&gt;&lt;td id="stakes"&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;
&lt;table id="inBet"&gt;
&lt;tr id="lami"&gt;
&lt;td width="190"&gt;&lt;/td&gt;&lt;td id="rightz"&gt;&lt;button class="button"&gt;Next&lt;/button&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr id="lamis"&gt;&lt;td id="leftz" width="190"&gt;&lt;button class="button"&gt;Back&lt;/button&gt;&lt;/td&gt;&lt;td id="sub"&gt;&lt;button class="button"&gt;Next&lt;/button&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;/table&gt;
&lt;/div&gt;
</code></pre>

<p>Below is my jquery code that performs the action.</p>

<pre><code> $(document).ready(function(e) {    
  $('.bestBets_category_outcome1').live('click',function(e){
        var homie = $(this).attr('id').replace('rgExp_','');
        var oddType = $('#oddsByTypeDropDown').val();
        var odd1 = $('#hodd_'+homie).text();
        var oddD = $('#draw_'+homie).text();
        var odd2 = $('#aodd_'+homie).text();
        var team1 = $('#home_'+homie).text();
        var team2 = $('#away_'+homie).text();
        $(this).css('background-color','#F93');
if(homie == true){
return false;
}else{
$('#lasvegas').append('&lt;table style="border-bottom:1px solid #000;"  id="home'+homie+'"&gt;&lt;tr&gt;&lt;td width="155"&gt;'+team1+' - '+team2+'&lt;/td&gt;&lt;td style="text-align:right;" id="imageSelect"&gt;&lt;img src="../images/yl.png" height="10" width="10" /&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;'+oddType+'&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;&lt;b&gt;'+team1+'&lt;/b&gt;&lt;/td&gt;&lt;td id="od'+homie+'"&gt;'+odd1+'&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;');
        var calc1 = parseFloat($('#odds').text());
        var calc3 = parseFloat($('#hodd_'+homie).text());
        if(!calc1){ calc1 = 0}
        if(!calc3){ calc3 = 0}
        var calc2 = (calc1 + calc3).toFixed(2);
        $('#odds').html(calc2);
        homie = true;
    }
}); 
$('.bestBets_category_outcome2').live('click',function(e){
        var homie = $(this).attr('id').replace('rgExp_','');
        var oddType = $('#oddsByTypeDropDown').val();
        var odd1 = $('#hodd_'+homie).text();
        var oddD = $('#draw_'+homie).text();
        var odd2 = $('#aodd_'+homie).text();
        var team1 = $('#home_'+homie).text();
        var team2 = $('#away_'+homie).text();
        $(this).css('background-color','#F93');
if(homie == true){
return false;
}else{
$('#lasvegas').append('&lt;table style="border-bottom:1px solid #000;" id="home'+homie+'"&gt;&lt;tr&gt;&lt;td width="155"&gt;'+team1+' - '+team2+'&lt;/td&gt;&lt;td style="text-align:right;"&gt;&lt;img src="../images/yl.png" height="10" width="10" id="imageSelect" /&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;'+oddType+'&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;&lt;b&gt;Draw&lt;/b&gt;&lt;/td&gt;&lt;td id="od'+homie+'"&gt;'+oddD+'&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;');
        var calc1 = parseFloat($('#odds').text());
        var calc3 = parseFloat($('#draw_'+homie).text());
        if(!calc1){ calc1 = 0}
        if(!calc3){ calc3 = 0}
        var calc2 = (calc1 + calc3).toFixed(2);
        $('#odds').html(calc2);
        homie = true;
    }
 });
$('.bestBets_category_outcome3').live('click',function(e){
        var homie = $(this).attr('id').replace('rgExp_','');
        var oddType = $('#oddsByTypeDropDown').val();
        var odd1 = $('#hodd_'+homie).text();
        var oddD = $('#draw_'+homie).text();
        var odd2 = $('#aodd_'+homie).text();
        var team1 = $('#home_'+homie).text();
        var team2 = $('#away_'+homie).text();
        $(this).css('background-color','#F93');
if(homie == true){
return false;
}else{
$('#lasvegas').append('&lt;table id="home'+homie+'" style="border-bottom:1px solid #000;"&gt;&lt;tr&gt;&lt;td width="155"&gt;'+team1+' - '+team2+'&lt;/td&gt;&lt;td style="text-align:right;"&gt;&lt;img src="../images/yl.png" height="10" width="10" id="imageSelect" /&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;'+oddType+'&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;&lt;b&gt;'+team2+'&lt;/b&gt;&lt;/td&gt;&lt;td id="od'+homie+'"&gt;'+odd2+'&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;');
        var calc1 = parseFloat($('#odds').text());
        var calc3 = parseFloat($('#aodd_'+homie).text());
        if(!calc1){ calc1 = 0}
        if(!calc3){ calc3 = 0}
        var calc2 = (calc1 + calc3).toFixed(2);
        $('#odds').html(calc2);
        homie = true;
    }
   });

$("#imageSelect").live('click',function(e){
    var pres = $(this).parent().parent().parent();
    var newValu = parseFloat($('#odds').text());
    var NewValue = (newValu - 1.5).toFixed(2);
    $('#odds').html(NewValue);

    $(pres).remove();
});
 });
</code></pre>
