jaywalking is illegal because the term jaywalking defines the illegal crossing of a street. https://en.wikipedia.org/wiki/Jaywalking
legal jaywalking is by definition not possible. what is however possible and legal is crossing the street away from a marked crossing. at least in europe and in most places in the world except the united states.
They changed the law in CA, it's still technically illegal, but police are directed to not cite anyone unless:
"... a reasonably careful person would realize there is an immediate danger of collision with a moving vehicle or other device moving exclusively by human power"
Turns out the police were mostly stopping non-white people for it