I would like to get the third or forth element and set its id.
I found that:
$('#menu li:first').attr('id', 'test')
its actually working but I only get the first element. On the other hand I tried to use the following but it is not working.
$('#menu li').get(0).attr('id', 'test')
Can someone explain how to get the desirable element? (eg 4 or 5) and set its id and why the second bunch of code it’s not working?
you can use
eq()method: