Showing a random list element depending on it's attribute's value

Showing a random list element depending on it's attribute's value

Hi guys!
I have a page which contains an <ul> list with 5 items. Each of those items has a data-weight 
attribute which corresponds to its importance in the list. I have to make only one random list item appear and use the weight to make sure that the most important one shows up more often than the least important item.

Does anybody has any idea?

Thanks in advance!