In the US, you would have to obtain a JD. That takes three years, entry to good law schools is very competitive, and the costs are high.
In the UK, it is much easier to obtain a place to study for a one year PGDL, which some places combine with an LLM, but not many of the best universities offer the PGDL. Cardiff is one that does. I don't think that any leading university offers the PGDL online.
You could also look at a two year senior status law degree, which is available at Cambridge and a few other universities, but not online as far as I know.
In the UK, if you don't have a law degree, you need a PGDL in order to take the Bar course (one year), obtain a pupillage (another year) and practise as a barrister. You can take the SQE to become a solicitor without a law degree or a PGDL, but doing so is not recommended. The grounding provided by a PGDL may assist in passing the SQE. You have to do two years of work experience, usually in the form of a training contract, to qualify as a solicitor.
Competition for pupillages and training contracts is intense.
In the US, after obtaining a JD you take the Bar examination in one or more States, usually after cramming for six weeks or so. NY and California are said to be the two hardest State Bar exams. It is also possible to take a State Bar exam if you are have a UK law degree or are qualified as a lawyer in the UK. Once you pass the Bar exam, you can be licensed to practise law without further training.