найти элемент
При прокрутке страницы вниз, догружатся еще элементы. Как найти id последнего. Пробовал через first chaild, он указывает на последний элемент который был при первой загрузке. А те элементы что догрузились так ненаходит
|
Цитата:
<!DOCTYPE html> <html> <head> <script src="http://code.jquery.com/jquery-latest.js"></script> <!-- <link rel="stylesheet" type="text/css" href="tmp.css" /> --> <style type="text/css"> </style> <script type="text/javascript"> $(document).ready(function (){ $('#b1').click(function (){ var n=$('div',document.body).length; $(document.body).append('<div id="d'+n+'">Text '+n+'</div>'); }); $('#b2').click(function (){ alert($(':last',document.body).get(0).id); }); }); </script> </head> <body> <button id='b1'>Add</button> <button id='b2'>Find</button> </body> </html> |
Цитата:
document.body.lastChild.id |
Часовой пояс GMT +3, время: 05:12. |