E' piu' complicato...

x = document.getElementsByTagName("p")
myID = x[x.length-1].id

ciao