.on方法无法在Firefox 21.0中运行

时间:2013-05-28 13:39:39

标签: jquery firefox click

下表将在Safari 5.1.9和Chrome中呈现,表单将显示。该表将呈现但该表单不会在Firefox 21.0中显示:

    $.each(json, function(index, value) {
        var posttimestamp = value.Post_timestamp;

    if(value.Post_timestamp != check) {
    var newpost='y';
        }
else {
    var oldpost='y';
        }

if(newpost) {
        $('#table2').append('<tr><td id="posttopic" colspan="2"><a href="forum24.php"    id=' + posttimestamp + '>' + topic + '</a></td><td></td></tr><tr><td id=' + "post" + posttimestamp + '>' + posttimestamp +'</td><td  id='+ "post" +posttimestamp+ 'colspan="3">' + post_txt + '</td><td>' + postuser + '</td><td>' + breed + '</td></tr>');

    }                       

      })

    $('td#posttopic').on("click", function(e) {
    e.preventDefault();
    var getid = event.target.id;
    alert(getid); // not working in Firefox

    $('div.form').show(); //not working Firefox

})

1 个答案:

答案 0 :(得分:1)

.on()可用于在DOM准备就绪后添加的元素,例如:

$('table').on("click", 'td#posttopic', function(e) {

这样,事件也会绑定到任何未来的元素(例如在你的情况下)。

相关问题