Jennifer Lopez ditched husband Marc Anthony because he failed to treat her "right" and she had enough self respect to "walk away," she said to Vanity Fair in an excerpted interview released Tuesday.

"To understand that a person is not good for you, or that the person is not treating you in the right way, or that he is not doing the right thing for himself -- if I stay, then I am not doing the right thing for me. I love myself enough to walk away from that now," the singer said in her first public explanation of why the power couple split after seven years.

"Sometimes we don't realize that we are compromising ourselves," she added.

Anthony and Lopez, who have three-year-old twins, announced July 23 that they will be seeking a divorce.

"For the first time in my life, I can truly say I am loving myself, I am doing loving things for myself," Lopez told the mag's contributing editor Lisa Robinson.

Lopez, 42, did not shut the door on love. The three-time marital loser said she is not jaded.

"Sometimes it doesn't work -- and that's sad," Lopez said.

"But I remain an eternal optimist about love. I believe in love ... It's still my biggest dream. I am positive -- determined to move forward with my life, bring up my babies, and do the best job I can as a mother, entertainer, and person," she said. "I really wanted this family to work. That was my biggest dream, and I worked hard at it. We both did."

Lopez had nothing but praise for Anthony as a musical force.

"We actually work great together, and he was always very supportive. Together we make magic -- and we did," she said. "He will always be in our lives. He will always hold a special place in my heart as the father of my children."

The September issue of Vanity Fair hits newsstands on Wednesday.

For more coverage please visit: myfoxny.com

Follow us on twitter.com/foxnewslatino
Like us at facebook.com/foxnewslatino