2014-11-17 73 views
0

我有一些單選按鈕的單選按鈕沒有標籤,但是隻要我將我的標籤類添加到單選按鈕來設置廣播風格根據我的主題按鈕,它停止工作。點擊功能沒有標籤但沒有標籤

這裏是JS

$("#bn_only_yes").click(function(){ 
$("#bn_yes").attr("checked", "checked"); 
}); 

這裏是

<!-- IF B_BN_ONLY --> 
<br /> 
<b>{L_30_0063}</b> 
<br /> 
<input type="radio" name="buy_now_only" value="n" {BN_ONLY_N} id="bn_only_no"> 
{L_029} 
<input type="radio" name="buy_now_only" value="y" {BN_ONLY_Y} id="bn_only_yes"> 
{L_030} 
<!-- ENDIF --> 

<!-- IF B_BN --> 
<br /> 
<b>{L_496}</b> 
<br /> 
<input type="radio" name="buy_now" id="bn_no" value="no" {BN_N}> 
{L_029} 
<input type="radio" name="buy_now" id="bn_yes" value="yes" {BN_Y}> 
{L_030} 
<input type="text" name="buy_now_price" id="bn" size="10" value="{BN_PRICE}"> 
<a href="converter.php" alt="converter" class="new-window">{CURRENCY}</a> 
<!-- ENDIF --> 

正常工作的代碼,這裏是增加了標籤類的造型,以我的輸入,但JS代碼停止代碼工作

<!-- IF B_BN_ONLY --> 
<br /> 
<b>{L_30_0063}</b> 
<br /> 
<label class="tz-radiobutton"> 
<input type="radio" name="buy_now_only" value="n" {BN_ONLY_N} id="bn_only_no"> 
{L_029} 
</label> 
<label class="tz-radiobutton"> 
<input type="radio" name="buy_now_only" value="y" {BN_ONLY_Y} id="bn_only_yes"> 
{L_030} 
</label> 
<!-- ENDIF --> 

<!-- IF B_BN --> 
<br /> 
<b>{L_496}</b> 
<br /> 
<label class="tz-radiobutton"> 
<input type="radio" name="buy_now" id="bn_no" value="no" {BN_N}> 
{L_029} 
</label> 
<label class="tz-radiobutton"> 
<input type="radio" name="buy_now" id="bn_yes" value="yes" {BN_Y}> 
{L_030} 
</label> 
<input type="text" name="buy_now_price" id="bn" size="10" value="{BN_PRICE}"> 
<a href="converter.php" alt="converter" class="new-window">{CURRENCY}</a> 
<!-- ENDIF --> 

我甚至嘗試添加輸入ID到標籤,但它仍然不會工作。

任何人都有任何想法,我可以如何在JS中包含標籤類以及輸入ID。

ADDING TZ-RADIOBUTTON CSS

header, footer, article, nav, #tz-hmenu-bg, .tz-sheet, .tz-hmenu a, .tz-vmenu a, .tz- slidenavigator > a, .tz-checkbox:before, .tz-radiobutton:before 
{ 
-webkit-background-origin: border !important; 
-moz-background-origin: border !important; 
background-origin: border-box !important; 

header, footer, article, nav, #tz-hmenu-bg, .tz-sheet, .tz-slidenavigator > a, .tz- checkbox:before, .tz-radiobutton:before 
{ 
display: block; 
-webkit-box-sizing: border-box; 
-moz-box-sizing: border-box; 
box-sizing: border-box; 
} 

label.tz-radiobutton:before 
{ 
background: #FFFFFF; 
-webkit-border-radius:8px; 
-moz-border-radius:8px; 
border-radius:8px; 
border:1px solid #8496A4; 
margin:0 auto; 
width:16px; 
height:16px; 
display: inline-block; 
vertical-align: top; 
content: ' '; 
} 
label.tz-radiobutton 
{ 
cursor: pointer; 
font-size: 13px; 
font-family: Arial, 'Arial Unicode MS', Helvetica, Sans-Serif; 
font-weight: normal; 
font-style: normal; 
line-height: 16px; 
display: inline-block; 
color: #323C43 !important; 
position: relative; 
} 

.tz-radiobutton>input[type="radio"] 
{ 
vertical-align: baseline; 
margin: 0 5px 0 0; 
} 

label.tz-radiobutton.active:before 
{ 
background: #FFFFFF; 
-webkit-border-radius:8px; 
-moz-border-radius:8px; 
border-radius:8px; 
border:1px solid #8496A4; 
margin:0 auto; 
width:16px; 
height:16px; 
display: inline-block; 
} 

label.tz-radiobutton.hovered:before 
{ 
background: #FFFFFF; 
-webkit-border-radius:8px; 
-moz-border-radius:8px; 
border-radius:8px; 
border:1px solid #8496A4; 
margin:0 auto; 
width:16px; 
height:16px; 
display: inline-block; 
} 

label.tz-radiobutton input[type="radio"] 
{ 
display: none; 
} 

label.tz-radiobutton.tz-checked:after 
{ 
content: url('../images/radiobuttonicon.png'); 
position: absolute; 
line-height: 12px; 
left: 2px; 
top: 2px; 
} 
+0

如果有一個標籤,當你使用輸入的ID應該沒有關係。它怎麼不起作用? – artm

+0

我用包含標籤的HTML製作了[FIDDLE](http://jsfiddle.net/5h0sjtqf/1/)。它按預期工作:當你點擊'#bn_only_yes'時,'#bn_yes'獲取屬性checked =「checked」' –

+0

順便說一句,CSS中缺少'}'行,'header,footer ...' 。 –

回答

0

你永遠不會看到檢查輸入,因爲

label.tz-radiobutton input[type="radio"] { 
display: none; 
} 
+0

該標籤添加樣式在我的主題中的輸入不是文本,看到的是{L_029}的位讀取一個名爲messages.inc.php的文件,並從messages.inc.php返回一些文本,即$ MSG ['029'] =「否「;基本上{L_029}返回文本NO。爲什麼我會在某些文本中添加一個單選按鈕類 – user3604052

+0

剛剛嘗試過,即使將結尾向上移動,以至於它只是包裝輸入 – user3604052

+0

,您是否可以發佈已使用的類「tz-radiobutton」以及用於您的瀏覽器測試? –

0

看到你的CSS我想你想的樣式到的#btn_yes標籤點擊:label.tz-radiobutton.tz-checked:after {}並顯示一個圖標。

1)在您發佈的CSS中,header, footer, ...上方的行中缺少關閉}

2)爲了得到工作風格,你需要一個類tz-checked添加到標籤:

$("#bn_only_yes").click(function(){ 
    $("#bn_yes").parent().addClass('tz-checked'); 
}); 

The third FIDDLE

如果你想設置的屬性checked上的複選框太:

$("#bn_only_yes").click(function(){ 
    $("#bn_yes").attr('checked', 'checked').parent().addClass('tz-checked'); 
}); 
+0

你的明星。感謝負荷爲這個有一些調整你給我提供什麼,我有它工作的偉大這裏是我的調整代碼[代碼] $( 「#bn_yes」)ATTR( 「選中」, 「檢查」); \t $( 「#bn_yes」)母公司。 ().addClass(「tz-checked」); \t $(「#bn_no」)。parent()。removeClass(「tz-checked」); [/ code] – user3604052