C# 在table的一行里jquery自动点击按钮钮 用jQuery操作显示一个页面

jquery动态给指定的table添加一行tr td
jquery动态给指定的table添加一行tr td
我的代码是
$('TABLe').append('&tr&&td&从&label&&input type=&text& name=&fqty& width=&50& /&件 --- &input type=&text& name=&eqty& width=&50& /&件&/label&&/td&&td&&input type=&text& name=&eqty& width=&50& /&&/td&&td&&a href=&#&&删除&/a&&/td&&/tr&')这样子是给全部页面的TABLE 都添加一行 我要的是给某个ID 叫XX的这个TABLE 添加。 还有就是添加出来的&input type=&text& name=&eqty& width=&50& /& 我怎么获取它的ID呢 还有就是我又怎么删除这一行呢。
按你的需求给你修改了一下,不知是否这种效果&table id=&app&&&/table&function remove() { $(&#app&tbody&).remove(); }function add(){ $(&#app&).append('&tr&&td&从&label&&input type=&text& name=&fqty& width=&50& /&件--- &input type=&text& name=&eqty& width=&50&/&件&/label&&/td&&td&&inputtype=&text& name=&eqty& width=&50& /&&/td&&td&&ahref=&javascript:void(0)& onclick=&remove()&&删除&/a&&/td&&/tr&');}
相关知识等待您来回答
互联网领域专家该表达验证的功能如下:
1、针对每个表单输入控件,用户可设置自定义级别和基本级别的匹配表达式和相应的提示信息;
2、用户离开表单输入控件时会自动校验,如果校验非法,该控件的边框底色会变红
3、如果在保存按钮上注册检查所有表单输入控件的代码,则会在点击按钮保存时检查所有输入表单控件,校验不合法的底色变红,
&&&&& 焦点自动定位到第1个输入非法的表达控件,也不会触发回发事件。
4、鼠标放在输入非法的表达控件上,会在输入控件的下方显示输入提示信息。
优势:1、验证表达式和提示信息可以通过服务器端属性注册实现,便于程序员使用,也便于扩展到从数据库获取设置信息;
2、替代使用aspnet提供的表达验证控件,既可以减少验证控件对布局的影响,因为验证和输入控件集成,增加了可维护性。
页面表单验证代码:
注:BaseRegExp为基本验证表达式,OrgRegExp为组织级正则表达式,EntRegExp为企业级验证表达式。一般的应用只要BaseRegExp即可.
(function(){
&&& var InvalidationCheck = function(){
&&&&//输入匹配检测
&&& function CheckValidation(input,regexp)
&&&&&&& if(!input)
&&&&&&&&&& input = &&;
&&&&&&& var theMatch =input.match(regexp);
&&&&&&& if(theMatch)
&&&&&&&&&&
&&&&&&& else
&&&&&&&&&&
&&&//创建或获取提示框,如果表单控件的输入不合法,一是该控件的边框颜色会变,而是鼠标经过时会提示规则信息,对客户比较友好。
&&& function CreateMsgDiv(msg)
&&&&&&& var theDiv = $('#MyMessageDiv');
&&&&&&& if(theDiv.length&=0)
&&&&&&&&&& theDiv = $(&&div id='MyMessageDiv' class='MyTooltip' style='display:block'&&+msg+&&/div&&);
&&&&&&& return theD
&&&&//获取元素的位置.
&&& function GetElementPos(el)
&&&&&&& var op = el[0];
&&&&&&& var theX = op.offsetL
&&&&&&& var theY = op.offsetT
&&&&&&& while(op =op.offsetParent)
&&&&&&&&&& theX += op.offsetL
&&&&&&&&&& theY += op.offsetT
&&&&&&& return [theX,theY];
&&& //获取输入规则信息,用于提示用户.
&&& function GetInputRegulation(obj)
&&&&&& var theRet = obj.attr(&inputregmsg&);
&&&&&& return ((theRet==null)?&&:theRet);
&& //设置表单输入控件的状态,true表示输入合法,false表示输入非法.
&&& function SetInputState(obj,state)
&&&&&&& if(state==false)
&&&&&&&&&& obj.attr(&inputstate&,&false&);
&&&&&&& else
&&&&&&&&&& obj.attr(&inputstate&,&true&);
& //获取表达输入控件状态.
&&& function GetInputState(obj)
&&&&&& return (obj.attr(&inputstate&) != &false&)?true:
&& //保存表单控件的样式,一旦输入合法后可恢复
&&& function SetOldClassName(obj)
&&&&&& var theOldStyle = obj.attr(&oldclassname&);
&&&&&& if(theOldStyle==null)
&&&&&&&&& var theClass = obj.attr(&className&);
&&&&&&&&& if(!theClass)
&&&&&&&&& {
&&&&&&&&&&&& theClass=&&;
&&&&&&&&& }
&&&&&&&&& obj.attr(&oldclassname&,theClass);
&&&&//获取当前样式类名
&&& function GetCurrClassName(obj,IsValid)
&&&&& var theStyle =
&&&&& if(IsValid==true)
&&&&&&&&& theStyle = obj.attr(&oldclassname&);
&&&&&&&&& if(!theStyle)
&&&&&&&&& {
&&&&&&&&&&& theStyle =&&;
&&&&&&&&& }
&&&&& else
&&&&&&&&& theStyle = &InputIsInvalid&;
&&&&& return theS
&& //设置当前显示样式.
&&& function SetCurrDisplayStyle(obj,IsValid)
&&&&&& obj.attr(&className&,GetCurrClassName(obj,IsValid));
&& //检查所有表单控件,适用于保存按钮.
&&& function CheckAllInput()
&&&&&&& var theFirstInvalidObj =&&
&&&&&&& //处理输入框
&&&&&&& var inputs = $(':text:enabled,textarea:enabled,select:enabled');
&&&&&&& for(var i=0;i&inputs.i++)
&&&&&&&&&& //获取OrgRegExp
&&&&&&&&&& var theCurrInput =$(inputs[i]);
&&&&&&&&&& var theCurrOK =
&&&&&&&&&& SetOldClassName(theCurrInput);
&&&&&&&&&& var theOrgRE = theCurrInput.attr(&OrgRegExp&);
&&&&&&&&&& if(theOrgRE)
&&&&&&&&&& {
&&&&&&&&&&&&&& theCurrOK = CheckValidation(theCurrInput.val(),theOrgRE);
&&&&&&&&&&&&&& SetCurrDisplayStyle(theCurrInput,theCurrOK);
&&&&&&&&&&&&&& if(theCurrOK==false)
&&&&&&&&&&&&&& {
&&&&&&&&&&&&&&&&& SetInputState(theCurrInput,false);
&&&&&&&&&&&&&&&&& if(!theFirstInvalidObj)
&&&&&&&&&&&&&&&&& {
&&&&&&&&&&&&&&&&&&&& theFirstInvalidObj = theCurrI
&&&&&&&&&&&&&&&&& }
&&&&&&&&&&&&&&&&&
&&&&&&&&&&&&&& }
&&&&&&&&&& }
&&&&&&&&&& //获取基本的校验表达式
&&&&&&&&&& var theBaseRE = theCurrInput.attr(&BaseRegExp&);
&&&&&&&&&& if(theBaseRE)
&&&&&&&&&& {
&&&&&&&&&&&&&& theCurrOK = CheckValidation(theCurrInput.val(),theBaseRE);
&&&&&&&&&&&&&& SetCurrDisplayStyle(theCurrInput,theCurrOK);
&&&&&&&&&&&&&& if(theCurrOK == false)
&&&&&&&&&&&&&& {
&&&&&&&&&&&&&&&&& if(!theFirstInvalidObj)
&&&&&&&&&&&&&&&&& {
&&&&&&&&&&&&&&&&&&&& theFirstInvalidObj = theCurrI
&&&&&&&&&&&&&&&&& }
&&&&&&&&&&&&&& }
&&&&&&&&&& }
&&&&&&&&&& SetInputState(theCurrInput,theCurrOK);
&&&&&&& //获取第一个输入非法的表单控件,默认会自动定位到该控件.
&&&&&&& return theFirstInvalidO
&&& this.ShowTooltipMsg =function(event)
&&&&&& var obj = $(this);
&&&&&& if(GetInputState(obj)==false)
&&&&&&&&& var Msg = GetInputRegulation(obj);
&&&&&&&&& if(Msg)
&&&&&&&&& {
&&&&&&&&&&&& var theDiv = CreateMsgDiv(Msg);
&&&&&&&&&&&& theDiv.appendTo('body');
&&&&&&&&&&&& var thePos = GetElementPos(obj);
&&&&&&&&&&&& theDiv.css(&left&,thePos[0] + event.offsetX + &px&);
&&&&&&&&&&&& theDiv.css(&top&,thePos[1] +23+ &px&);
&&&&&&&&& }
&&& this.HiddenTooltipMsg =function(event)
&&&&&& var obj = $(this);
&&&&& if(GetInputState(obj)==false)
&&&&&&& var theDiv = $(&#MyMessageDiv&);
&&&&&&& if(theDiv.length&0)
&&&&&&&&&& $(&body&)[0].removeChild(theDiv[0]);
&&& this.DoValidationAlbert =function()
&&&&&&& var theFirstObj = CheckAllInput();
&&&&&&& if(theFirstObj)
&&&&&&&&&& try
&&&&&&&&&& {
&&&&&&&&&&&&& theFirstObj.focus();
&&&&&&&&&& }
&&&&&&&&&& catch(ex)
&&&&&&&&&& {
&&&&&&&&&& }
&&&&&&&&&&
&&& this.CheckInputValidation=function()
&&&&&&&&&& //获取OrgRegExp
&&&&&&&&&& var theCurrInput =$(this);
&&&&&&&&&& var theCurrOK =
&&&&&&&&&& //设置旧的样式类.
&&&&&&&&&& SetOldClassName(theCurrInput);
&&&&&&&&&& var theOrgRE = theCurrInput.attr(&OrgRegExp&);
&&&&&&&&&& if(theOrgRE)
&&&&&&&&&& {
&&&&&&&&&&&&& theCurrOK = CheckValidation(theCurrInput.val(),theOrgRE);
&&&&&&&&&&&&&& SetCurrDisplayStyle(theCurrInput,theCurrOK);
&&&&&&&&&& }
&&&&&&&&&& if(theCurrOK==false)
&&&&&&&&&& {
&&&&&&&&&&&&& SetInputState(theCurrInput,false);
&&&&&&&&&&&&&
&&&&&&&&&& }
&&&&&&&&&& //获取基本的校验表达式
&&&&&&&&&& var theBaseRE = theCurrInput.attr(&BaseRegExp&);
&&&&&&&&&& if(theBaseRE)
&&&&&&&&&& {
&&&&&&&&&&&&&& theCurrOK = CheckValidation(theCurrInput.val(),theBaseRE);
&&&&&&&&&&&&&& SetCurrDisplayStyle(theCurrInput,theCurrOK);
&&&&&&&&&& }
&&&&&&&&&& SetInputState(theCurrInput,theCurrOK);
&&& this.Init = function()
&&&&&& $(':text:enabled,textarea:enabled,select:enabled').mouseenter(this.ShowTooltipMsg)
&&&&& .mouseleave(this.HiddenTooltipMsg)
&&&&& .mousemove(this.ShowTooltipMsg)
&&&&& .keypress(this.HiddenTooltipMsg)
&&&&& .blur(this.CheckInputValidation);
&&&&& $(document.forms[0]).submit(this.DoValidationAlbert);
& $InputCheck = new InvalidationCheck();
用法:要运行该代码,需要JQuery库。如果不需要中间回发,只需要调用Init初始化一下,验证正则表达式可通过服务器端服务控件注册属性的方式加入。
如果需要回发,则控件事件触发函数挂接,需要在服务器端来完成。
如果利用服务器控件,有两种方法完成验证表达式和提示信息的方式:一是通过对控件注册属性来完成,一是可以简单继承一下控件,将需要的信息作为服务器控件的属性,并输出到客户端属性。我个人偏向于后一种方法,因为这样,程序员既可以通过所见即所得的方式使用,而且这些验证信息可以从数据库读取,适合规模应用,而且事件的注册也可以在控件中自动完成,免除客户端注册或者手工设置的麻烦。
* 以上用户言论只代表其个人观点,不代表CSDN网站的观点或立场
访问:608703次
积分:10680
积分:10680
排名:第508名
原创:423篇
转载:12篇
评论:290条
文章:10篇
阅读:11324
文章:10篇
阅读:35930
文章:18篇
阅读:29218
阅读:13939
文章:13篇
阅读:24882
阅读:9493
阅读:13537
(8)(25)(25)(14)(10)(33)(7)(2)(2)(2)(1)(3)(1)(1)(4)(4)(8)(6)(9)(8)(4)(11)(7)(8)(9)(11)(6)(7)(8)(10)(17)(10)(11)(18)(26)(61)(25)(1)(2)(1)(2)(2)jquery如何获取table每一行的第一列
[问题点数:40分,结帖人tengfei5200]
jquery如何获取table每一行的第一列
[问题点数:40分,结帖人tengfei5200]
不显示删除回复
显示所有回复
显示星级回复
显示得分回复
只显示楼主
相关帖子推荐:
2010年 总版技术专家分年内排行榜第一2009年 总版技术专家分年内排行榜第一
2011年 总版技术专家分年内排行榜第二
本帖子已过去太久远了,不再提供回复功能。1774人阅读
$(window).load(function () {
//$(&#plc_lt_zoneContent_pageplaceholder_pageplaceholder_lt_zoneLeft_LISA_GiftBrowser_lstElem td:last&).css(&border-style&, &dotted&);
$(&#plc_lt_zoneContent_pageplaceholder_pageplaceholder_lt_zoneLeft_LISA_GiftBrowser_lstElem td:last&).addClass(&part-d&);
* 以上用户言论只代表其个人观点,不代表CSDN网站的观点或立场
访问:190878次
积分:2949
积分:2949
排名:第4924名
原创:85篇
转载:166篇
评论:22条
(2)(3)(1)(8)(11)(15)(6)(3)(4)(1)(10)(7)(10)(2)(6)(7)(1)(4)(3)(6)(2)(2)(1)(6)(2)(1)(2)(1)(2)(1)(1)(8)(2)(4)(2)(2)(2)(2)(1)(1)(2)(11)(3)(1)(4)(1)(1)(2)(1)(5)(1)(5)(2)(4)(8)(6)(3)(3)(5)(3)(2)(5)(7)(1)(4)(1)(4)(3)(1)jquery 一个&table&共10行,我在上面插入一行。。原来的第10行变11行了
jquery 一个&table&共10行,我在上面插入一行。。原来的第10行变11行了
在插入的同时,删除超出10行的最后一行(如果没超出10行不删除);&table& 也是js动态生成,插入的那行是另个JS控制。
if($(&tr&).length()&10) {$(&tr:last&).remove();}是这个意思么?
相关知识等待您来回答
编程领域专家

我要回帖

更多关于 jquery ui table 的文章

 

随机推荐