我可以在选中复选框时禁用文本框,但如果有任何内容,我无法弄清楚如何清除文本框。
<input type="text" id="form_sc1"/>
<input type="checkbox" id="form_setchange"/>
JQuery
$(document).ready(function(){
if($('input.form_setchange').is(':checked')){
$("#form_sc1").attr("disabled", "disabled");
}
答案 0 :(得分:1)
试试这个
<Grid Margin="30,20,0,20" x:Name="MeGrid" Loaded="MeGrid_Loaded" Visibility="{Binding Path=_isMyMessage, Converter={StaticResource BoolToVisibilityConverter}}">
<StackPanel >
<TextBlock HorizontalAlignment="Right" Foreground="#00c0d4" Margin="0,0,100,0" Text="{Binding Path=CreatedDate, Converter={StaticResource TimeSinceConverter}}" />
<StackPanel Orientation="Horizontal" HorizontalAlignment="Right">
<Grid Background="#ffffff" Height="auto" Width="auto" MaxWidth="300" MinWidth="50">
<StackPanel Background="White">
<RichTextBox Name="MeRich" Background="White" MaxHeight="600" Foreground="Red"
FontFamily="Segoe UI" Margin="10,0,10,0" VerticalAlignment="Center"
TextWrapping="Wrap" Height="auto"
Width="auto" MinWidth="50"
MaxWidth="300"
local:Properties.Html="{Binding Path=MessageText}">
</RichTextBox>
<readMore:Readmore Source="{Binding Path=MessageText}" Visibility="{Binding ActualHeight,
ElementName=MeRich, Converter={StaticResource ReadMoreVisibilityConverter}}" ></readMore:Readmore>
<!--<TextBlock Margin="10,0,10,0" VerticalAlignment="Center" Foreground="Black" TextWrapping="Wrap" Height="auto" Width="auto" MinWidth="50" MaxWidth="300" Text="{Binding Path=MessageText}"
/>-->
<ListBox ScrollViewer.VerticalScrollBarVisibility="Disabled" ItemsSource="{Binding Path=AttachmentList}">
<ListBox.ItemTemplate>
<DataTemplate>
<Grid Margin="0,5,0,5">
<Button Click="Image_Download" Loaded="Button_Loaded" Tag="{Binding .}" Width="80" Height="80" >
<Button.Template>
<ControlTemplate TargetType="Button">
<Border HorizontalAlignment="Center" VerticalAlignment="Center" >
<ContentControl Content="{TemplateBinding Content}"/>
</Border>
</ControlTemplate>
</Button.Template>
<Image Source="/Resources/Drawable/c_image.png" Tag="{Binding .}" />
</Button>
<ProgressBar VerticalAlignment="Bottom" IsIndeterminate="true" Visibility="Collapsed" Style="{StaticResource CustomIndeterminateProgressBar}" />
</Grid>
</DataTemplate>
</ListBox.ItemTemplate>
</ListBox>
</StackPanel>
</Grid>
<Rectangle Margin="20,0,0,0" VerticalAlignment="Top" RadiusX="50" RadiusY="50" Width="80" Height="80">
<Rectangle.Fill>
<ImageBrush ImageSource="{Binding Path=UserPictureURL}"/>
</Rectangle.Fill>
</Rectangle>
</StackPanel>
</StackPanel>
</Grid>
在这里工作JSFiddle https://jsfiddle.net/86Lv2urz/1/
答案 1 :(得分:0)
试试这个:
$('input:checkbox').on('click', function(){
$('input:text').prop('disbaled', 'disabled');
$('input:text').val('');
});
答案 2 :(得分:0)
你也可以尝试这个 -
$('#form_setchange').attr("value", "");
OR
$('#form_setchange').val('');
答案 3 :(得分:0)
if($('input.form_setchange').is(':checked')){
$("#form_sc1").prop("disabled", true).val('');
}
答案 4 :(得分:0)
您可以尝试下面的代码吗
$('#form_setchange').change(function() {
var $check = $(this);
if ($check.prop('checked')) {
$("#form_sc1").val('');
$("#form_sc1").attr("disabled", "disabled");
} else {
$("#form_sc1").removeAttr("disabled");
}
});
希望它有所帮助...