首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >左转get行id

左转get行id
EN

Stack Overflow用户
提问于 2017-10-26 08:57:32
回答 1查看 455关注 0票数 0

我使用查询手机向左滑动,这是可行的,并给我一个提示窗口,上面写着,你滑动了。但我没有得到警报的身份。

代码语言:javascript
复制
    $(function(){
    // Bind the swipeleftHandler callback function to the swipe event on div.box
    $(".row").on( "swipeleft", swipeleftHandler );
    // Callback function references the event target and adds the 'swipeleft' class to it
    function swipeleftHandler( e ){
        $id =  e.target.id;
        alert( 'You swiped ' + $id  );
    }
    });
代码语言:javascript
复制
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery-mobile/1.4.5/jquery.mobile.min.js"></script>
<link href="https://cdnjs.cloudflare.com/ajax/libs/jquery-mobile/1.4.5/jquery.mobile.min.css" rel="stylesheet"/>

<table class="alert-table" cellspacing="0" cellpadding="0">         
    <tr>
        <th>Date/Time</th>               
        <th>Alert</th>
        <th>Acknowledged By</th>
        <th>&nbsp;</th>
    </tr>   
    <tr id="12345" class="row {% cycle 'tr-1' 'tr-2' %}">
        <td>01/01/2017 3:41</td>
        <td>
            Device: Server <br/>
            Component: CPU <br />             
            Alert: 100%
        </td>
        <td>Bill Jones</td>
        <td></td>

    </tr>
    <tr id="12346" class="row {% cycle 'tr-1' 'tr-2' %}">
        <td>01/01/2017 4:41</td>
        <td>
            Device: Switch 02<br/>
            Component: Port 10 <br />             
            Alert: Down
        </td>
        <td>Fred Smith</td>
        <td></td>

    </tr>
</table>

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2017-10-26 09:08:26

尝试$id = $(this).attr('id');而不是$id = e.target.id;。它应该能工作

票数 2
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/46949918

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档