English 中文(简体)
如何在选收无线电台时在文字现场清除文字
原标题:How to clear text inside text field when radio button is select

目前,我有这个无线电台。

  1. Eletronics
  2. Computers
  3. Others

如果是无线电台,我想做的是什么。 选择了其他,我希望显示一个投入文本领域,让用户类型。

在我选择<代码>时,我想做些什么。 其他和输入领域的一些东西类型,然后,当我选择回到<条码>[>/条码>或<条码>Computers时,我要澄清我在投入领域撰写的案文。

请向我提供 Java或 j的解决办法。

这里是我的法典样本。 请核对:。 http://jsfiddle.net/dnGKM/

最佳回答

<>>>>>

$( input:radio ).on( click , function() {
    if($(this).attr( id ) ==  others ) {
        $( #showhide ).css( opacity , 1.0);
   } else {
       $( #showhide ).css( opacity , 0).find( input:text#others_text ).val(  );
    }  
});​

rel=“nofollow>DEMO

问题回答

你们可以这样做:

document.getElementById("others_text").value=  ;

明确投入领域。

请在您的法典中加入以下行文:

document.getElementById("others_text").value =   ;

现在,它喜欢:

document.getElementById("others").addEventListener("click", function()
{
    document.getElementById("others_text").value =   ;
    document.getElementById("showhide").style.opacity = 1;
}, false);
document.getElementById("computers").addEventListener("click", function()
{
    document.getElementById("showhide").style.opacity = 0;
}, false);
document.getElementById("electronics").addEventListener("click", function()
{
    document.getElementById("showhide").style.opacity = 0;
}, false);​

这对你有益。

采用这一解决办法:

$(function() {
      $( input[type="radio"] ).click(function() {
       if($(this).attr( id ) ==  others ) {
           $( #others-text ).show();
       } else {
           $( #others-text ).hide();
           $( #others-text ).val(  );
       }
   });
})

这里有一份联合材料。

http://jsfiddle.net/dnGKM/4/

页: 1 女士们:

CSS:

.hidden {
    display: none;
}

传真:

<label for="electronics">Electronics</label>
<input type="radio" id="electronics" name="rdbutton" />
<label for="computers">Computers</label>
<input type="radio" id="computers" name="rdbutton" />
<label for="others">Others</label>
<input type="radio" id="others" name="rdbutton" />
<input type="text" id="others-text" name="others-text" class="hidden" />

JS:

$(function() {
    $( input[type="radio"] ).click(function() {
        if($(this).attr( id ) ==  others ) {
            $( #others-text ).removeClass( hidden );
        } else {
            $( #others-text ).addClass( hidden );
            $( #others-text ).val(  );
        }
    });
});

=============超值=====================================================

<input type="radio" name="rdo" value="1" checked="checked" />Electronics
<input type="radio" name="rdo" value="2" />Computers
<input type="radio" name="rdo" value="3" />Others

==========jQuery=======================================jQuery=============================

  $( input[name=rdo] ).change(function() {
         var a = $(this).val();
         if (a != 3) {
             $( #textboxid ).hide();
         }else{
             $( #textboxid ).val(  );
             $( #textboxid ).show();
         }
   });
$("#<%=text1.ClientID%>").val(  );




相关问题
selected text in iframe

How to get a selected text inside a iframe. I my page i m having a iframe which is editable true. So how can i get the selected text in that iframe.

How to fire event handlers on the link using javascript

I would like to click a link in my page using javascript. I would like to Fire event handlers on the link without navigating. How can this be done? This has to work both in firefox and Internet ...

How to Add script codes before the </body> tag ASP.NET

Heres the problem, In Masterpage, the google analytics code were pasted before the end of body tag. In ASPX page, I need to generate a script (google addItem tracker) using codebehind ClientScript ...

Clipboard access using Javascript - sans Flash?

Is there a reliable way to access the client machine s clipboard using Javascript? I continue to run into permissions issues when attempting to do this. How does Google Docs do this? Do they use ...

javascript debugging question

I have a large javascript which I didn t write but I need to use it and I m slowely going trough it trying to figure out what does it do and how, I m using alert to print out what it does but now I ...

Parsing date like twitter

I ve made a little forum and I want parse the date on newest posts like twitter, you know "posted 40 minutes ago ","posted 1 hour ago"... What s the best way ? Thanx.

热门标签