Fix #1322

https://github.com/mybb/mybb/issues/1322
Also simplified the file a bit using chaining and variables so jQuery
won't have to look for selector each multiple times for no reason.
Merge pull request #1323 from Destroy666x/fix1322

Fix #1322