Fix jQuery usage bugs ...

... simplify html and reformat code