我的网页上有3个单选按钮,如下所示:
<label for="theme-grey">
<input type="radio" id="theme-grey" name="theme" value="grey" />Grey</label>
<label for="theme-pink">
<input type="radio" id="theme-pink" name="theme" value="pink" />Pink</label>
<label for="theme-green">
<input type="radio" id="theme-green" name="theme" value="green" />Green</label>Run Code Online (Sandbox Code Playgroud)
在jQuery中,我希望在单击这三个中的任何一个时获取所选单选按钮的值.在jQuery中我们有id(#)和class(.)选择器,但如果我想按名称找到一个单选按钮怎么办,如下所示?
$("<radiobutton name attribute>").click(function(){});
Run Code Online (Sandbox Code Playgroud)
请告诉我如何解决这个问题.
我对KnockoutJS很新,我喜欢到目前为止所见过的东西.目前,当视图模型的可观察属性绑定到文本框的文本属性(输入类型=文本)时,ViewModel仅更新文本框的blur事件.有没有办法在文本框的更改事件上更新视图模型?我尝试在"init"中的文本框上连接更改事件处理程序时创建自定义绑定处理程序,但它在某种程度上不起作用.这是否正确实现这一目标?或者有更简单的方法吗?
我有一个菜单列表:
<ul>
<li><a href="#about" id="about">??? ?????</a></li>
<li><a href="#products" id="products" >?????????</a></li>
<li><a href="#farm" id="farm" >????????????</a></li>
<li><a href="#gallery" id="gallery" >???????</a></li>
<li><a href="#contacts" id="contacts">???????? ???</a></li>
</ul>
Run Code Online (Sandbox Code Playgroud)
我使用地址插件沿ajax返回/转发,但我有一个小错误,我无法解决.
当我点击菜单时,如果页面已滚动,它会移动页面,直到菜单出现在页面顶部,但我不需要它.
有没有一种方法可以禁用此行为?
非常感谢.
我在List.Find()上得到一个System.IndexOutOfRangeException.问题是它不一致,并且只在生产环境中发生.浏览List.Find(谓词匹配)方法的MSDN文档,但它确实说明索引超出范围异常.在什么情况下会从List.Find()方法抛出System.IndexOutOfRangeException?
这发生在ASP.Net应用程序中.代码在静态方法中,如下所示:
private static T GetReflectionInfo<T>(object obj, string memberName) where T : System.Reflection.MemberInfo
{
var knownInfos = new List<MemberInfo>();
/// populate the list
/// this line is where the exception is thrown. T is the generic type passed in.
T info = (T) knownInfos.Find(item => item is T && item.Name.EqualsIgnoreCase(memberName));
}
Run Code Online (Sandbox Code Playgroud)
[更新] - 问题结果证明其中一个节点有问题.感谢您的回答和评论.