如何为动态生成的行写onkeyup

时间:2015-07-24 11:28:47

标签: php

for($tr=1;$tr<=$rows;$tr++)
{

echo "<tr>";
for($td=1;$td<=$cols;$td++)
    {
        for($td=1;$td<=1;$td++)
        {

            echo "<td><input type='text' name='bhk[$tr][$td]'  value='$tr' disabled></td>";

        }
        for($td=2;$td<=$cols;$td++)
        {

            echo "<td><input type='text' name='bhk[$tr][$td]'></td>";

        }

    }

    echo "</tr>";
}

如何为动态生成的行写onkeyup。我需要使用onkeyup隐藏一些列我是如何实现的

3 个答案:

答案 0 :(得分:0)

试试这个

$(document.body).on("onkeyup",".class", function () {
    //do you what you want here
});

答案 1 :(得分:0)

您可以使用纯JavaScript或jQuery实现此目的:

的JavaScript

// add this in your input tags
..<input type='text' name='bhk[$tr][$td]' onkeyup="makeItHappen(this.value)" ..>...
function makeItHappen(val) {
    // do whatever you like
}

的jQuery

// add a class to your input tags
..<input type='text' name='bhk[$tr][$td]' class="make-it-happen" ..>...

// add this to your script
<script>
$(function() {
    $('.make-it-happen').keyup(function() {
         // do whatever you like
    });
});
</script>

答案 2 :(得分:0)

您必须在JavaScript中编写 $scope.ConfirmTicketPayOut = function (ticketPin, username) { $scope.ticketPin = ticketPin; localStorage.setItem("pin", ticketPin); accountDataProviderService.confirmTicketPayOut(ticketPin, username) .then(function (response) { $scope.confirmTicketPayOut = response; if ($scope.confirmTicketPayOut.Result == true) { $window.open('/print'); } }); localStorage.clear(); } $scope.print = function () { setTimeout(function () { print()}, 1000); } 事件侦听器,然后将其动态发送到PHP脚本。

请注意可能会稍有延迟。