gpt4 book ai didi

javascript - 当我单击单选按钮时如何使用 ClearText textarea

转载 作者:太空宇宙 更新时间:2023-11-04 03:36:28 25 4
gpt4 key购买 nike

1.Step(Unicode RadioButton is Checked)
TextetArea notClearUnicode Radio 被选中但是 Zawgyi Radio 被选中 Textarea 清晰

2.Step(Zawgyi RadioButton is Checked)
TextetArea notClearZawgyi Radio被选中但Unicode Radio被选中时Textarea 清晰

<label><input type="radio" name="kb" value="uni" id="unikb"/>Unicode</label>
<label><input type="radio" name="kb" value="zawgyi" id="zawgyikb"/>Zawgyi</label>
<textarea id="desp" class="form-control rows="5"></textarea>

如何使用Jquery

   $("input").click(function(){

if ( $(this).val()=='uni' || $(this).val()=='zawgyi'){
$("textarea#desp").val();
}
else{
$("textarea#desp").val('');
}
}) ;

我想要这种风格

enter image description here
textarea 不清楚。

enter image description here
文本区域清晰



enter image description here
文本区域不清楚。

enter image description here
文本区域清晰

SEEDEMO

最佳答案

您的 else 子句错误,jsfiddle 已修复:http://jsfiddle.net/hLuk2bhx/9/现在它正在工作......(:

$("input[type='radio']").click(function(e) {
if ( $(this).val()=='uni'){
$("textarea").val('');
}else{
$("textarea").val('');
}
});

在您发表评论后,我更新了您的代码,使其更加动态,我创建了一个 var 来控制最后一条语句。

var lastChecked = undefined;
$("input[type='radio']").click(function(e) {
if ( $(this).val() != lastChecked && (typeof lastChecked !== 'undefined')){
$("textarea#desp").val('');
}
lastChecked = $(this).val();
});

希望对您的问题有所帮助。 fiddle :http://jsfiddle.net/hLuk2bhx/23/

关于javascript - 当我单击单选按钮时如何使用 ClearText textarea,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25497576/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com