我如何把TR值进入。点击事件? 我想能够通过TR ID成updatedb.php作为良好的SQL更新

输入

<head>
<script src="jquery-1.3.2.min.js" type="text/javascript"></script>
<script src="jquery.jeditable.mini.js" type="text/javascript"></script>

<script type="text/javascript">

    $(document).ready(function() {

var global= ""

$('.click').click(function() {
    var $this = $(this);
    var $tr = $this.closest('tr');

alert($tr.attr('id'));
global= $tr.attr('id');

});


    $('.click').editable('updatedb.php?test=123', { 
        indicator : "<img src='indicator.gif'>",
        tooltip   : "Click to edit...",
        onblur : 'submit',
        style  : "inherit"

    });


    });

</script>

</head>
<body>      
    <tr id=1>
    <td>
        <span class="click" style="display: inline">Funny click here testing!</span>
        <br />
        </td>    
    </tr>
    <tr id=2>
        <td>    
        <span class="click" style="display: inline">Second inline!</span>
        </td>
    <tr>    
</body>
</html>

这里

嗨,jeditable没有接班人。我终于设法得到价值为全局。但现在面临的另一个问题。 Jeditable不允许我在额外的价值传递...

我试图 可编辑的( 'updatedb.php?测试= 123' 然后回声“START”。 $ _ POST [“测试”。 “END”

我也尝试过其他方式,不工作。

有帮助吗?

解决方案

您可能要检查出的jQuery插件jEditable,继任为可编辑的。 链接: http://www.appelsiini.net/projects/jeditable

回到你的问题,你可以要求使用父母任何一方(),最近()父母的属性或让你的榜样的TR节点的ID()。我建议对父(),因为它需要你离开嵌套完全一样在你的榜样的HTML。最好使用父母()或最接近()的过滤器。

$(document).ready(function() {
    $('.click').each(function() {
        var $this = $(this);
        var $tr = $this.closest('tr');
        // Do stuff with $tr like checking it, extracting $tr.attr('id') ...
        $this.editable('updatedb.php', {
            indicator : "",
            tooltip : "Click to edit...",
            onblur : 'submit',
            style : "inherit"
        });
    });
} 

其他提示

$(".click").click(function(){

 alert($(this).text())   // Funny click here testing! or Second inline!  (o/p);
 alert($(this).parent().parent().attr("id"))  // 1 or 2 (o/p);

});
许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top