我有像这样的html代码
<ul>
<li>Some Name <a class="rud" href="#">remove</a><input type="text" value="one" readonly="readonly" name="array" /></li>
<li>Some other name <a class="rud" href="#">remove</a><input type="text" value="two" readonly="readonly" name="array" /></li>
</ul>
当我点击<a>
时我想要重命名输入名称和值。
结果应该是
<li>Some Name <a class="rud" href="#">undo</a><input type="text" value="one" readonly="readonly" name="deleted" /></li>
Jquery 文档就绪点击事件
$(document).ready(function() {
$(".rud").click(function() {
// alert(this).next().val();
// get input button in this <li></li>.
// change name
$(this).text("undo");
});
});
最佳答案
$(".rud").click(function() {
$(this)
.text("undo") // change link text
.next(':input') // go to nex input
.attr('name','deleted'); // chage name attr
});
<强> DEMO
关于javascript - JQuery 下一个选择器或类似的东西,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10872278/