jquery 点击按钮获取动态添加的 tr中 input text 内容

jquery 点击按钮获取动态添加的 tr中 input text 内容,第1张

按照要求,在点击每一行的修改按钮,需要获取对应行的第一列input的value值,对应的js代码参考下方:

function change(){

   var text = $(this)parents('tr')children('td:eq(0)')children('input')val();

   consolelog(text);

}

还有更加简便的方法:在forEach循环生成tr和td元素时,按照如下规则生成td元素:

<c:forEach items="${projectHot26005s}" var="zslb">

<tr id="sj1">

<td><input type="text" id="txt${zslbprojectId}" value="" maxlength="2"></td>

<td>${zslbprojectName }</td>

<td><button class="btn btn-red r3 margin" onclick="btnDelete('${zslbprojectId }')">删除</button></td>

<td><button class="btn btn-red r3 margin" onclick="change('${zslbprojectId}')">修改</button></td>

</tr>

</c:forEach>

这样在change方法中就能通过唯一的id来定位到指定的input,既而获取到value值:

function change(id){

   var text = $("#txt" + id)val();

   consolelog(text);

}

Form formPreview = new Form();

public Leaf(string name) : base(name) { }

public override void Add(Component c)

{

ConsoleWriteLine("Cannot add to a leaf");

}

public override void Remove(Component c)

{

ConsoleWriteLine("Cannot remove to a leaf");

}

public override void Display(int depth)

{

ConsoleWriteLine(new string('-',depth)+name);

}

}

$(btn)bind('click', function(){

var value = $(input)val();

var param = {v:value};

$post(url,param,function(){})

});

以上列子用了jquery

通过js获取input的值,然后通过ajax将值传到后台。当然这样做的话,你后台需要一个ajax接口来支持。post里面的url,就是你接口的地址。

以上就是关于jquery 点击按钮获取动态添加的 tr中 input text 内容全部的内容,包括:jquery 点击按钮获取动态添加的 tr中 input text 内容、如何在confirm里添加text文本框,并获取text文本框的值、在jsp中没有form表单的情况下怎么,能通过点击button按钮触发js方法 获得text的内容等相关内容解答,如果想了解更多相关内容,可以关注我们,你们的支持是我们更新的动力!

欢迎分享,转载请注明来源:内存溢出

原文地址:https://54852.com/web/9669084.html

(0)
打赏 微信扫一扫微信扫一扫 支付宝扫一扫支付宝扫一扫
上一篇 2023-04-30
下一篇2023-04-30

发表评论

登录后才能评论

评论列表(0条)

    保存