Strange Code: JS Console.log() outputs twice with different output

I am trying to read an ID from a table row in my html via a checkbox/edit button contained in the row. The row has id of "name_id#" Here is the code: $('.EditButton').click(function edit() { var patchID = parseInt($(this).attr('id').slice(5)); console.log("patchID is : " + patchID.toString()); ... }); I have tried using substring and slice, and without parseInt. Everything seems to grab the ID number correctly, however when I log it, it outputs this: > patchID is : 63 > patchID is : NaN Is there something totally wrong with my code? When I try and use a jquery "get" using the ID, it works, but it also throws an error because it tries to "get" with both the ID # and "NaN". Here is the html for my table rows: @foreach (var patch in patches) {
} Thanks for your help!

以上就是Strange Code: JS Console.log() outputs twice with different output的详细内容,更多请关注web前端其它相关文章!

赞(0) 打赏
未经允许不得转载:web前端首页 » jQuery 答疑

评论 抢沙发

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址

前端开发相关广告投放 更专业 更精准

联系我们

觉得文章有用就打赏一下文章作者

支付宝扫一扫打赏

微信扫一扫打赏