相关疑难解决方法(0)

jQuery无法处理添加的行

我有一张桌子,允许用户输入多个库存

<table class="table1" id="table1">
  <thread>
    <tr>
      <th scope="col">Item Name</th>
      <th scope="col">Qty</th>
      <th scope="col">Rate</th>
      <th scope="col">Amount</th>
    </tr>
  </thread>
  <tbody>
    <tr>
     <td><input type="text"/></td>
     <td><input type="text" class="num" id="qty"/></td>
     <td><input type="text" class="num" id="rate"/></td>
     <td><input type="text" class="num" id="amt"/></td>
   </tr>
 </tbody>
</table>
<a id="add"><button>Add</button></a>
Run Code Online (Sandbox Code Playgroud)

这段代码是添加新行:

<script type="text/javascript">
  $(document).ready(function() {
    $("#add").click(function() {
      var newrow = $("<tr><td><input type="text"/></td><td><input type=\"text\" id=\"qty\"/></td><td><input type="\text\" id="\rate\"/></td><td><input type="\text\" id="\amt\"/></td></tr>");
    newrow.insertAfter('#table1 tbody>tr:last');
    return false;
  });
  $(".num").keyup(function() {
    var id = $(this).attr('id');
    if (id == 'qty') {
      var i = parseFloat($("#rate").val())
      if (!isNaN(i)) {
        var …
Run Code Online (Sandbox Code Playgroud)

html javascript jquery

0
推荐指数
1
解决办法
1649
查看次数

javascript对象中的JQuery事件

我有一个javascript对象

function A()
{
    this.ini = function()
    {
        $('#test').html('<button id="click" >Hi</button>');
    }    

    $('#click').on('click',function(){
        alert('Hi');
    });
}
Run Code Online (Sandbox Code Playgroud)

http://jsfiddle.net/G2MUE/1/

但我有一个问题,没有使用onClick事件.

谢谢你的帮助

javascript jquery

0
推荐指数
1
解决办法
140
查看次数

为什么我不能从TD内的删除按钮中删除TR

我只想从当前删除的图像中删除TR元素...

我这样做:

$( "#btnDelete").click(function() {  
    $(this).parent().parent().remove();
});
Run Code Online (Sandbox Code Playgroud)

小提琴

我不明白为什么它不起作用

有小费吗?

html jquery

0
推荐指数
1
解决办法
374
查看次数

使用.on的Click事件不会触发附加元素

我的问题是,即使我使用.on,添加了类的添加div的click事件也不会触发.这是我的页面脚本.

$(".added").on("click", function () { alert("halo") });

$("#nextAdress").on("click",function (event) {
    event.preventDefault();
    $("#trainerRegistrationFields").append('<div class="added">adsa</div>');
}
Run Code Online (Sandbox Code Playgroud)

你可以帮助我,所以点击事件也会在添加了类的动态添加元素上触发吗?

提前告诉你

jquery append

-1
推荐指数
1
解决办法
4453
查看次数

$(this).parent().remove()不起作用

即使这是" 事件处理程序不处理动态内容 " 的重复问题,即使按照那里给出的答案,我仍然遇到同样的问题.请帮忙 ....

    userinfo.topics.forEach(ele=>{
            $("#topics_subscribed").append(`<li class="list-group-item col-4">${ele} &nbsp;<i style="color:red;font-size:.7em;" class="removeitem fa fa-times"/></li>`) ;
        });


    $(document).on('click', '.removeitem', ()=> {
        console.log('clicked') ; 
        $(this).parent().remove() ; 
    });
Run Code Online (Sandbox Code Playgroud)

请在将此标记为重复之前回答其原因.如何解决这个问题?(我会在答复后立即删除这个问题....)

html javascript jquery

-3
推荐指数
1
解决办法
66
查看次数

标签 统计

jquery ×5

html ×3

javascript ×3

append ×1