2017-07-28 79 views
0
   EventPrices += "<div class='after-price' id=divPrice>"; 
         if (localStorage.getItem('SelectedRoleName') != null) 
         { 
          if (localStorage.getItem('SelectedRoleName').toString().trim() == "Admin") { 
           EventPrices += "<span class='price'><input type='radio' value='" + Item.PriceId + "' id='chkEventPrices' class='fa fa-check' name='chkEventPrices' title='" + Item.Price + "' onclick='CalculateTotal();'><label> $" + Item.Price + " </label> </span> "; 
          } 
          else { 
           EventPrices += "<span class='price'><input type='radio' value='" + Item.PriceId + "' id='chkEventPrices' disabled= 'disabled' class='fa fa-check' name='chkEventPrices' title='" + Item.Price + "' onclick='CalculateTotal();'><label> $" + Item.Price + " </label> </span> "; 
          } 
         } else { 
          EventPrices += "<span class='price'><input type='radio' value='" + Item.PriceId + "' id='chkEventPrices' disabled= 'disabled' class='fa fa-check' name='chkEventPrices' title='" + Item.Price + "' onclick='CalculateTotal();'><label> $" + Item.Price + " </label> </span> "; 
         } 


         EventPrices += "<span class='date'>After " + moment(Item.EarlyBirdDate).format("MMM DD, YYYY") + " </span>"; 
         EventPrices += "</div></div>"; 
         EventPrices += "<div><span id='spnEventPriceLiteralDetails_" + i + "'>" + EventPriceLiteraldetals + "</span></div>"; 


        } 


        EventPrices += "</div><br/>"; 
        i++; 
       }); 

的任何地方更改單選按鈕的狀態這是我code.now如果我對特定單選按鈕單擊它是taking..i想,如果我在盒僅單選按鈕將選擇點擊。當我點擊的div

+0

您可以發佈完整的代碼和修改你的話嗎?現在很混亂。 –

+0

您可以使用標籤來達到此目的,請參閱https://stackoverflow.com/questions/1527721/using-label-for-on-radio-buttons – gjijo

回答

0

$('input[type=radio]').click(function() { 
 
    $("#isClicked").text("selected radio value is " + ($('input[type=radio]:checked').val() == "1" ? "Male" : "Female")); 
 
});
.hidden { 
 
    display: none; 
 
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script> 
 
<label for="r1"> Male 
 
    <input type="radio" class="hidden" name="group1" id="r1" value="1" /> 
 
</label> 
 
<label for="r2"> FeMale 
 
    <input type="radio" class="hidden" name="group1" id="r2" value="2" /> 
 
</label> 
 
<br /> 
 
<div id="isClicked"></div>

請檢查。在這裏每當用戶點擊一個標籤時,其相應的單選按鈕點擊事件就會被觸發。

0

按照你Q我猜你的功能正在單擊單選按鈕。

因此,讓我們拿你radio按鈕類是.radio和'div'類是.test在這種情況下,如果你想我們可以用`.trigger'的jQuery去。 如:

$('body).on('click',`.test`,function(){ 
    $('.radio').trigger('click'); 
}); 

這將作爲每me.ty