解决方案 »
- js跨域Ajax访问数据
- javascript基础差,请帮看一下下面的代码那里有问题。
- 如何替换onclick事件?
- 求助
- 如何检测FORM元素是否获得了焦点?
- jquery实现单选和不选的功能问题——求高手!
- 设置了left但是DOM中left为空
- javascript与c#代码之间的交互问题。
- JAVASCRIPT现在最新版本是不是1。4你们用的是哪个版本,最新版本功能增加了很多吗?
- location.replace()的用法正确吗?在线等待。。。。
- window.showModalDialog里面iframe失效了
- JS 如何将时间中的“秒”转换成字符串,两位数的秒值中取最后一位,并转换成字符串。
还要求有光标,有光标的只有<input type="text">和<textArea>,这两个应该都不能实现这个效果吧
<html>
<body>
<div onclick="this.onfocus();" onfocus="document.getElementsByName('joke')[document.getElementsByName('joke').length-1].focus()">
<div style="color:#ff0000;background-color:silver;display:inline;">aaa</div>
<input name="joke" type="text" style="width:1px;border-width:0px;text-autospace">
<div style="color:#00ff00;background-color:silver;display:inline;">bbb</div>
<input name="joke" type="text" style="width:1px;border-width:0px;text-autospace">
<div style="color:#0000ff;background-color:silver;display:inline;">ccc</div>
<input name="joke" type="text" style="width:1px;border-width:0px;text-autospace">
</div></body>
<script language="javascript">
function ini(){
for(var i=0;i<document.getElementsByName('joke').length;i++){
document.getElementsByName('joke')[i].onkeydown=function(){
//这里检查按下退格、方向键等,做出相应处理
//如果是退格,就移除上一个<div>
//大致就这个意思
};
}
}
</script>
</html>
<html>
<body>
<div onclick="this.onfocus();" onfocus="document.getElementsByName('joke') [document.getElementsByName('joke').length-1].focus()">
<div style="color:#ff0000;background-color:silver;display:inline;">aaa </div>
<input name="joke" type="text" style="width:1px;border-width:0px;text-autospace">
<div style="color:#00ff00;background-color:silver;display:inline;">bbb </div>
<input name="joke" type="text" style="width:1px;border-width:0px;text-autospace">
<div style="color:#0000ff;background-color:silver;display:inline;">ccc </div>
<input name="joke" type="text" style="width:1px;border-width:0px;text-autospace">
</div> </body>
<script language="javascript">
function ini(){
for(var i=0;i <document.getElementsByName('joke').length;i++){
document.getElementsByName('joke')[i].onkeydown=function(){
//这里检查按下退格、方向键等,做出相应处理
//如果是退格,就移除上一个 <div>
//大致就这个意思
};
}
}
</script>
</html>
re:
获取textarea的内容,用正则或用split分隔font出来的数组就知道几个选项!
re:
也就是用js控制光标在textarea的位置吧!要想跨浏览器有点难度!如果是ie的话!网上有很多