Martin Suchan – BloQ Random #WPdev stuff

14May/110

Creating ‘select multiple’ element in IE6 using jQuery

I was facing recently strange problem with creating <select> tag with 'multiple' attribute in IE6. Normally it's done using $("<select>").attr("multiple", true), but this does not work in IE6 - the crated select element was simple every time, without multiple choices. Setting 'multiple' attribute in IE6 programatically just doesn't work. I spent lot of time finding some workaround, but the solution I discovered is pretty simple, just use this object constructor:

$("<select multiple='multiple'>")

It's not 100% clean solution, but it works in IE6 and that's important.

If you know better solution, you might update the jQuery I created for this issue: http://bugs.jquery.com/ticket/9231

Tagged as: , No Comments
15Feb/111

Disabling key down event propagation in JavaScript

Imagine this non-trivial problem: you have div element with overflow: auto; and long text inside. The scrollbar appears automatically. Normally when the div is focused pressing keys Up or Down causes moving the content up or down. But what if you don't want to scroll the content on keydown event?