始终在文本框中设置courser(即当鼠标左键单击时) [英] Set courser always in textbox (i.e when out side mouse click Also)
本文介绍了始终在文本框中设置courser(即当鼠标左键单击时)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
大家好..
i在网页中有一个文本框我需要在文本框中每次点击文本框时都设置courser位置也是courser应该只在文本框中..
i尝试像
hi all..
i have one text box in a web page i need to set courser position every time in that text box when clicked out side of text box also courser should be in text box only..
i tried like
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default2.aspx.cs" Inherits="Default2" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title>Set Courser Focus</title>
<script src="js/jquery-1.6.2.min.js" type="text/javascript"></script>
<link href="js/jquery-ui-1.8.11.custom.css" rel="stylesheet" type="text/css" />
<script src="js/jquery-ui-1.8.11.custom.min.js" type="text/javascript"></script>
<script language="javascript" type="text/javascript">
$(document).ready(function() {
//
// Click Event
$("#body1").click(function(event) {
$('#txtname').focus();
});
});
</script>
</head>
<body id="body1" onload="$('#txtname').focus();">
<form id="form1" runat="server">
<div >
<asp:TextBox ID="txtname" AutoCompleteType="None" runat="server"></asp:TextBox>
</div>
</form>
</body>
</html>
case1:在页面加载时它正在工作
case2:单击body标签中的每个位置时,它将重点放在文本框上
case3:但是当外部鼠标点击时它没有关注文本框
i需要在文本框中始终设置courser位置
任何人都可以帮助我ase
提前感谢..
case1: on page load it is working
case2: on clicking every where in body tag it is focusing on text box
case3:but it is not focusing on text box when outside body mouse click
i need to set always courser position in text box
can any one help me please
thanks in advance..
推荐答案
( document )。ready ( function (){
//
// 点击事件
(document).ready(function() { // // Click Event
( #body1)。click( function (event){
("#body1").click(function(event) {
(' #txtname' )。焦点();
});
});
< / script >
< / head >
< body id = body1 onload =
('#txtname').focus(); }); }); </script> </head> <body id="body1" onload="
这篇关于始终在文本框中设置courser(即当鼠标左键单击时)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文