improved fixes of bug in previous commit, applied to more cases

Apparently, since I last ran this, the HTML "dir" attribute
(it means, "direction of text") became a standard and/or
became more widely supported.  I was using it with some crap that
isn't valid.  My guess is that that several browsers couldn't handle
it, and for some reason that manifested in the jQuery attr failing
to retrieve it (even though getAttribute worked just fine, and even
though the version of jQuery I was using didn't change).