我contentEditable在我的网站上使用div标签,我注意到使用Firefox时有一个奇怪的问题.
这是示例源代码:
<html>
<head>
</head>
<body>
<div contentEditable="true" style="margin-left:auto;
margin-right:auto; height:200px; width:200px; border-style:solid;
border-color:black; border-width:1px;"></div>
</body>
</html>
Run Code Online (Sandbox Code Playgroud)
以下是重现的步骤.
contentEditable 有焦点,光标在div内闪烁,但div中没有文字contentEditable
div我在Ubuntu上用Firefox 3.6.3和Windows XP上的Firefox 3.5重现了这个错误.Chrome不会发生这种情况.
关于为什么会发生这种情况以及如何解决这个问题的想法?
编辑:一种可能的解决方法可能是手动设置光标所在的位置.有谁知道如何做到这一点?我一直在网上搜索,但看起来没有W3支持.
谢谢!
在Ruby中,我有一个对象哈希.每个对象都有一个类型和一个值.我试图设计一个有效的函数,可以获得散列中特定类型的所有对象的平均值.
以下是当前如何实现此示例的示例:
#the hash is composed of a number of objects of class Robot (example name)
class Robot
attr_accessor :type, :value
def initialize(type, value)
@type = type
@value = value
end
end
#this is the hash that inclues the Robot objects
hsh = { 56 => Robot.new(:x, 5), 21 => Robot.new(:x, 25), 45 => Robot.new(:x, 35), 31 => Robot.new(:y, 15), 0 => Robot.new(:y, 5) }
#this is the part where I find the average
total = 0
count = 0 …Run Code Online (Sandbox Code Playgroud)