Depends on ur kid n kid's age. Children may not fully understand what no is but because we use it so much to them, they also want to use it back on us to have things their way and it's a fun thing for them sometimes. Like the mummy suggested, create a situation where it cannot be just yes (obey) and no. But with at least 3 options
Squat down at an eye level with your child. Ask them while looking into their eyes. Ask why no? Do you not like it? If not, give two choices, let them decide on one.
I'll let it be and divert his attention. sometimes the more we enforce the more they will continue doing.
Give him/her and so that he/she is able to make choices.