首页 \ 问答 \ jquery获取中的下一个输入元素值(jquery get next input element value in )

jquery获取中的下一个输入元素值(jquery get next input element value in )

我有一块html表格,其内容类似于

<table>
    <tr>
        <td>
            <input type="text" class="myclass" name="first_ele[]" value="100" />
        </td>
        <td>
            <input type="text" class="anotherclass" name="secon_ele[]" value="" />
        </td>
    </tr>
</table>

我有一块jquery,它将获取包含类“myclass”的元素的值,并获得正确的值。 我需要获取下一个输入元素的值。 仅供参考,该表格获取动态添加的行。 我的问题是我不知道如何指向下一个可用的输入元素。

我的jquery获取具有类“myclass”的元素如下。

$('.tInputd').keyup(function(){
    var disc = $(this).val();
});

非常感谢您的帮助。


I have some piece of an html table which reads like

<table>
    <tr>
        <td>
            <input type="text" class="myclass" name="first_ele[]" value="100" />
        </td>
        <td>
            <input type="text" class="anotherclass" name="secon_ele[]" value="" />
        </td>
    </tr>
</table>

I have a piece of jquery that will get the value of the element that contains class "myclass" on keyup and I am getting the proper value. I need to get the value of the next input element. FYI , The table gets rows added dynamically. My issue is I don't know how to point to the next available input element.

my jquery to get the element which has the class "myclass" is as follows.

$('.tInputd').keyup(function(){
    var disc = $(this).val();
});

your help is greatly appreciated.


原文:https://stackoverflow.com/questions/19092123
更新时间:2022-04-23 22:04

最满意答案

那么,你可以使用泛型来改变你的方法签名:

TType ComapreMethod<TType>(TType obj1, TType obj2) where TType : IComparable

并在从if(obj1>obj2)if (obj1.CompareTo(obj2) > 0)方法中更改代码(并且不要忘记处理obj1和obj2为null的情况)。

在这种情况下,您将能够传递一些实现IComparable接口的类的方法值,包括int,double和float。


Well, you can change your method signature using generics:

TType ComapreMethod<TType>(TType obj1, TType obj2) where TType : IComparable

and change your code in method from if(obj1>obj2) to if (obj1.CompareTo(obj2) > 0) (and don't forget to handle cases of obj1 and obj2 being null).

In this case you will be able to pass to your method values of some class that implemented IComparable interface, including ints, doubles and floats.

相关问答

更多
  • 一种方法是首先将它们转换为图像数据,然后进行比较。 - (BOOL)image:(UIImage *)image1 isEqualTo:(UIImage *)image2 { NSData *data1 = UIImagePNGRepresentation(image1); NSData *data2 = UIImagePNGRepresentation(image2); return [data1 isEqual:data2]; } One way is to convert ...
  • pubic class Category { Integer id; int catId; String catTitle; .......................... @Override public boolean equals(Object other) { return (other instanceOf Category) && equate((Category) other); } private boolea ...
  • java.lang.Class从java.lang.Class继承其equals()实现: public boolean equals(Object obj) { return (this == obj); } 因此,比较类的方式并不重要。 此外,类加载器是无关紧要的,因为行为将保持不变。 java.lang.Class inherits its equals() implementation from java.lang.Object: public boolean equals(Object ob ...
  • 你是对的,给定的集合关系形成一个图形。 仔细观察,您会发现这样创建的图形实际上是一个有向无环图 (DAG)(正如@RalfKleberhoff在评论中所指出的那样)。 这使得检查关系( compare )变得更加容易。 为了保持一致性,我将假设set(A, B) => A > B => B is a child of A节点(确切地说是如何生成邻接列表)。 一旦我们有了DAG,我们的compare(X, Y)算法就像如下: compare(X, Y): if X is descendant of Y ...
  • 试试这个比较两个resultSet的逻辑: while(rs1.next()){ // Compare till rs1 reach to the last record while(rs2.next()){ if(){ // Coding } } //will move resultSet cursor to first position. rs2.first(); } but i'm using like <%if(rs2.next()){%> <% topi ...
  • 那么,你可以使用泛型来改变你的方法签名: TType ComapreMethod(TType obj1, TType obj2) where TType : IComparable 并在从if(obj1>obj2)到if (obj1.CompareTo(obj2) > 0)方法中更改代码(并且不要忘记处理obj1和obj2为null的情况)。 在这种情况下,您将能够传递一些实现IComparable接口的类的方法值,包括int,double和float。 Well, you can chan ...
  • 这里是一个linq函数( IEnumerable.Except(...) ),它将执行您所需的操作。 http://msdn.microsoft.com/en-us/library/bb336390.aspx Here is a linq function (IEnumerable.Except(...)) that will do what you need. http://msdn.microsoft.com/en-us/library/bb336390.aspx
  • 因此,严格来说,“变量的类型”总是存在,并且可以作为类型参数传递。 例如: val x = 5 def f[T](v: T) = v f(x) // T is Int, the type of x 但取决于你想做什么,这对你没有帮助。 例如,可能不想知道变量的类型是什么,但要知道值的类型是否是某种特定的类型,例如: val x: Any = 5 def f[T](v: T) = v match { case _: Int => "Int" case _: String => "String" ...
  • 最简单的方法是减去彼此的偏移量。 它返回一个可以比较的TimeSpan 。 var timespan = DateTimeOffset1 - DateTimeOffset2; // timespan < TimeSpan.FromDays(40); // timespan.Days < 40 我倾向于将它添加到另一个传入TimeSpan的方法中,因此你不仅限于几天或几分钟,而只是一段时间。 就像是: bool IsLaterThan(DateTimeOffset first, DateTimeOffset ...
  • 使用下划线: 你可以得到两个对象的键(使用Object.keys ),对它们做一个交集(使用_.intersect )并遍历它们并比较: var keys1 = Object.keys(a); var keys2 = Object.keys(b); var common = _.intersection(keys1, keys2); common.forEach(function(key) { if(a[key] === b[key]) { // they are equal ...

相关文章

更多

最新问答

更多
  • 您如何使用git diff文件,并将其应用于同一存储库的副本的本地分支?(How do you take a git diff file, and apply it to a local branch that is a copy of the same repository?)
  • 将长浮点值剪切为2个小数点并复制到字符数组(Cut Long Float Value to 2 decimal points and copy to Character Array)
  • OctoberCMS侧边栏不呈现(OctoberCMS Sidebar not rendering)
  • 页面加载后对象是否有资格进行垃圾回收?(Are objects eligible for garbage collection after the page loads?)
  • codeigniter中的语言不能按预期工作(language in codeigniter doesn' t work as expected)
  • 在计算机拍照在哪里进入
  • 使用cin.get()从c ++中的输入流中丢弃不需要的字符(Using cin.get() to discard unwanted characters from the input stream in c++)
  • No for循环将在for循环中运行。(No for loop will run inside for loop. Testing for primes)
  • 单页应用程序:页面重新加载(Single Page Application: page reload)
  • 在循环中选择具有相似模式的列名称(Selecting Column Name With Similar Pattern in a Loop)
  • System.StackOverflow错误(System.StackOverflow error)
  • KnockoutJS未在嵌套模板上应用beforeRemove和afterAdd(KnockoutJS not applying beforeRemove and afterAdd on nested templates)
  • 散列包括方法和/或嵌套属性(Hash include methods and/or nested attributes)
  • android - 如何避免使用Samsung RFS文件系统延迟/冻结?(android - how to avoid lag/freezes with Samsung RFS filesystem?)
  • TensorFlow:基于索引列表创建新张量(TensorFlow: Create a new tensor based on list of indices)
  • 企业安全培训的各项内容
  • 错误:RPC失败;(error: RPC failed; curl transfer closed with outstanding read data remaining)
  • C#类名中允许哪些字符?(What characters are allowed in C# class name?)
  • NumPy:将int64值存储在np.array中并使用dtype float64并将其转换回整数是否安全?(NumPy: Is it safe to store an int64 value in an np.array with dtype float64 and later convert it back to integer?)
  • 注销后如何隐藏导航portlet?(How to hide navigation portlet after logout?)
  • 将多个行和可变行移动到列(moving multiple and variable rows to columns)
  • 提交表单时忽略基础href,而不使用Javascript(ignore base href when submitting form, without using Javascript)
  • 对setOnInfoWindowClickListener的意图(Intent on setOnInfoWindowClickListener)
  • Angular $资源不会改变方法(Angular $resource doesn't change method)
  • 在Angular 5中不是一个函数(is not a function in Angular 5)
  • 如何配置Composite C1以将.m和桌面作为同一站点提供服务(How to configure Composite C1 to serve .m and desktop as the same site)
  • 不适用:悬停在悬停时:在元素之前[复制](Don't apply :hover when hovering on :before element [duplicate])
  • 常见的python rpc和cli接口(Common python rpc and cli interface)
  • Mysql DB单个字段匹配多个其他字段(Mysql DB single field matching to multiple other fields)
  • 产品页面上的Magento Up出售对齐问题(Magento Up sell alignment issue on the products page)