我有以下代码:
<script type="text/javascript">
function editLabel(source) {
source.innerHTML = '<input type="text" value="' + source.innerHTML + '"/>';
source.onclick = null;
source.children[0].focus()
}
function setLabel(source) {
if (source.children[0].value != '') {
source.onclick = function () { editLabel(source); };
source.innerHTML = source.children[0].value;
}
}然后在我的asp标签中:
<asp:Label ID="lblName" runat="server" onfocusout="setLabel(this);" onclick="editLabel(this);" Text='<%# Bind("GroupDescription") %>'></asp:Label>这在Chrome和IE中运行良好,但在Firefox中不起作用。
这是因为Firefox只支持onblur。
我尝试将onblur添加到标签和文本框中,但不起作用。
我能做些什么?
谢谢
发布于 2013-02-06 22:06:07
查看jQuery,并将函数绑定到事件。即检查悬停、模糊和聚焦。如果你想做任何真正的web开发,像jQuery这样的框架是必要的。
http://api.jquery.com/hover/
http://api.jquery.com/blur/
http://api.jquery.com/focus/
有关示例,请参阅此处:http://jsfiddle.net/turiyag/fQV3p/
$("#blurry").hover(function() {
log("Hover In!");
}, function(){
log("Hover Out!");
});
$(":text").blur(function() {
log("Blurred from textbox with value: " + $(this).val());
});
$(":text").focus(function() {
log("Focus given to textbox with value: " + $(this).val());
});https://stackoverflow.com/questions/14730669
复制相似问题