有没有人知道是否有办法配置一个jquery ui可选元素来单击它时取消选中所选元素?有点像切换.如果已选中,则取消选择,否则执行默认行为.
谢谢.
在我用.select()鼠标悬停在输入框中时选择文本后,我执行了以下操作:
HTML:
<input type="text" class="hoverAble" value="hover here"/><br />
Run Code Online (Sandbox Code Playgroud)
jQuery的:
$(".hoverAble").mouseenter(function() {
this.select();
}).mouseleave(function() {
//I can't figure what to put here.
});
Run Code Online (Sandbox Code Playgroud)
看到这里. 警告它正常运行(在jsfiddle中)你必须在结果框中单击一次.
主要思想是按预期mouseleave工作.
正如您可能已经注意到的那样,当您将鼠标悬停时我无法找到取消选择文本的方法并避免这种情况:

我有一个简单的php文件上传表单,如下所示:
<form action="upload_file.php" method="post" onsubmit="return validateForm()" enctype="multipart/form-data">
<label for="file">Files:</label>
<input type="file" name="file[]" id="file"><button type="button">Remove File</button>
<input type="file" name="file[]" id="file"><button type="button">Remove File</button>
<input type="submit" name="submit" value="Submit">
</form>
Run Code Online (Sandbox Code Playgroud)
我想添加一个功能删除文件按钮,以取消选择所选的文件.那可能吗 ?
谢谢您的帮助.
我有一个包含100多个复选框的工作簿.
它们是表单控件复选框
我想一次取消选择它们
这将它们设置为false.
Sub clearcheck()
ActiveSheet.CheckBoxes.Value = False
End Sub
Run Code Online (Sandbox Code Playgroud)
这适用于活动工作表.我希望这段代码适用于整个工作簿
我已经尝试寻找代码并搞清楚清除复选框但不是更明智的.
如果有人能指导我,我真的很感激
谢谢
我有一个Jtree和2个按钮来选择和取消选择所有节点.我做了这样的尝试:
selectAll = new JButton("Select all");
selectAll.addActionListener(new ActionListener (){
@Override
public void actionPerformed(ActionEvent e) {
int row = 0;
while (row < curvesTree.getRowCount())
{
curvesTree.expandRow(row);
row++;
}
int entradasTree = curvesTree.getRowCount();
for(int i=0; i<entradasTree; i++){
TreePath path = curvesTree.getPathForRow(i);
curvesTree.setSelectionPath(path);
}
}
});
unselectAll = new JButton("Unselect all");
unselectAll.addActionListener(new ActionListener (){
@Override
public void actionPerformed(ActionEvent e) {
curvesTree.clearSelection();
}
});
Run Code Online (Sandbox Code Playgroud)
unselect按钮似乎正在工作,但select all只扩展了JTree并选择了最后一个节点.我认为每次以编程方式选择节点时,我都会取消选择前一个节点.
JTree的配置如下:
curvesTree = new JTree(rootNode);
curvesTree.setExpandsSelectedPaths(true);
curvesTree.getSelectionModel().setSelectionMode(TreeSelectionModel.
DISCONTIGUOUS_TREE_SELECTION);
Run Code Online (Sandbox Code Playgroud) 我是iOS开发的新手,我直接从IOS 5开始.我创建了一个故事板,其中包含一个tabview控制器作为其rootviewcontroller.我已经放了两个标签.
我想最初取消选择/取消选中所有标签.我该怎么做呢?我尝试了以下内容
UIView *view = [[UIView alloc]initWithNibName:@"view" bundle:[NSBundle mainBundle]];
[self.tabBarController setSelectedViewController:nil];
[self.tabBarController setSelectedViewController:view];
Run Code Online (Sandbox Code Playgroud)
我添加了标识符"view"的视图.
但这不起作用,它给出了错误:
unrecognized selector sent to instance
Run Code Online (Sandbox Code Playgroud)
我也试过以下
[self.tabBarController.tabBar setSelectedItem:nil];
Run Code Online (Sandbox Code Playgroud)
但它说
'NSInternalInconsistencyException',原因是:'不允许直接修改由标签栏控制器管理的标签栏.'
我已在第一个选项卡的控制器中尝试了此代码.我想这样做是因为我想在第一个标签视图的顶部放置一个默认视图,并在下面任何一个标签上单击使用后隐藏它.
我的问题很简单,但我真的没有找到任何解决方案.我有一个表setSelectable(true),setMultiselect(false),setImmediate(true).
通过首先单击并使用箭头在表格中移动它可以正常工作.但是,如果我再次单击已经被选中的行,则它将被取消选中.怎么预防呢?我想一直选择一行.
我似乎无法清除数据绑定的WPF ListBox的SelectedItems集合.我试过调用ListBox.SelectedItems.Clear(),我尝试将SelectedIndex设置为-1,将SelectedItem设置为null并调用ListBox.UnselectAll().在调试时,似乎分配没有采取或某些东西正在重置SelectedItems集合,但我不知道是什么.我在SelectionChanged回调中放置了一个断点,它永远不会被意外命中,但SelectedItems.Count成员总是至少为1(有时大于1,因为此ListBox的选择模式是MultiExtended).
有没有人见过这个,知道我做错了什么?这个问题看起来和这个问题完全相同: WPF - 如何从ListView中清除选择?
除了那篇文章,Sonny Boy正在使用ListView,而我正在使用ListBox.在任何情况下,投票的答案是调用ListView.UnselectAll(),这在我的情况下不起作用.
我觉得我必须做一些非常明显错误的事情,因为清理选择应该非常简单.
注意:为了清楚起见,我不想从ListBox中删除选择,我只是不想选择任何内容.
谢谢!
<ListBox Background="{StaticResource ResourceKey=DarkGray}" Name="lbx_subimageThumbnails" Margin="6,6,6,0" ItemsSource="{Binding ElementName=lbx_thumbnails, Path=SelectedItem.Swatches}" Style="{StaticResource WPTemplate}" SelectionMode="Extended" Height="{Binding ElementName=sld_swatchRows, Path=Value}" VerticalAlignment="Top" SelectionChanged="lbx_subimageThumbnails_SelectionChanged" DataContext="{Binding}">
<ListBox.ItemsPanel>
<ItemsPanelTemplate>
<WrapPanel HorizontalAlignment="Stretch" />
</ItemsPanelTemplate>
</ListBox.ItemsPanel>
<ListBox.ItemContainerStyle>
<Style TargetType="{x:Type ListBoxItem}">
<Setter Property="Visibility" Value="{Binding Path=Vis}" />
</Style>
</ListBox.ItemContainerStyle>
<ListBox.ItemTemplate>
<DataTemplate>
<Grid Width="270" Height="270" Margin="5,5,5,5" Tag="{Binding}" Name="lbx_swatchThumbnail" Background="{StaticResource ResourceKey=LightGray}" PreviewMouseLeftButtonDown="lbx_swatchThumbnail_PreviewMouseLeftButtonDown" PreviewMouseMove="lbx_swatchThumbnail_PreviewMouseMove">
<Grid.LayoutTransform>
<ScaleTransform CenterX="0" CenterY="0" ScaleX="0.50" ScaleY="0.50" />
</Grid.LayoutTransform>
<Grid.ContextMenu>
<ContextMenu>
<MenuItem Header="Sync selected" Click="btn_syncSwatch_Click" />
<MenuItem Header="Re-export selected" Click="btn_exportSelected_Click"/>
<MenuItem Header="Set as …Run Code Online (Sandbox Code Playgroud) 我有几个可折叠的复选框,我正在尝试检查/取消选中该部分中的所有框.
HTML
目前,当我单击主复选框时,它只是打开并关闭可折叠对话框.
<li data-role="collapsible" id="educationlayers">
<h3>
<input type="checkbox" name="education" id="education" class="layers"/>
<label for="education">Education</label>
</h3>
<fieldset data-role="controlgroup">
<input type="checkbox" data-mini="true" name="education" id="daycare" class="layers"/>
<label for="daycare">Day Care</label>
<input type="checkbox" data-mini="true" name="education" id="elementary" class="layers"/>
<label for="elementary">Elementary</label>
<input type="checkbox" data-mini="true" name="education" id="intermediate" class="layers"/>
<label for="highschool">High School</label>
<input type="checkbox" data-mini="true" name="education" id="postsecondary" class="layers"/>
<label for="postsecondary">Post Secondary School</label>
</fieldset>
</li>
<li data-role="collapsible" id="emergencylayers">
<h3>
<input type="checkbox" name="emergency" id="emergency" class="layers"/>
<label for="emergency">Emergency</label>
</h3>
<fieldset data-role="controlgroup">
<input type="checkbox" data-mini="true" name="emergency" id="ambulance" class="layers"/>
<label for="ambulance">Ambulance Station</label>
<input type="checkbox" …Run Code Online (Sandbox Code Playgroud) 我正在使用tinyMCE 4.x,并希望以编程方式删除整个编辑器文本中的任何设置格式。它应该执行removeFormat 命令的操作。到目前为止我来了:
tinymce.execCommand('selectAll', true, 'texteditor');
tinymce.execCommand('RemoveFormat', true, 'texteditor');
Run Code Online (Sandbox Code Playgroud)
removeFormat 仅适用于预先选定的文本,因此我在RemoveFormat 之前执行“SelectAll”。这工作正常,但在删除格式后所有内容都保持选中状态。所以问题是:有没有一种方法可以删除任何格式而不选择之前的所有格式?如果否,如何取消选择之前选择的文本?(之后我尝试将焦点集中在文本编辑器上,但选择仍然存在)。我确信有一个简单的方法只是在网上找不到它。