lastChild not working

前端 未结 6 842
予麋鹿
予麋鹿 2021-01-25 01:20

I have the following code:







        
6条回答
  •  花落未央
    2021-01-25 01:39

    this is what I would have done, but I'm not clear as to if it's what you want:

    $(function () {
        var lastchild = $('#div div:last-child').attr('id');
        alert(lastchild);
    });
    

    http://jsfiddle.net/pFjPS/

    also, I don't believe classes or ids can start with numbers, so your markup is probably not valid

    edit : HTML5 supports it, but is not generally recommended.

提交回复
热议问题