[jQuery] Simple select box utility functions

[jQuery] Simple select box utility functions

<span style="font-family: courier new,monospace;">jQuery.fn.selectOption = function() {</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">  return this.jsAttr("selected", true)
</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">}</span><br style="font-family: courier new,monospace;"><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">
jQuery.fn.unselectOption = function() {</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">  return this.jsAttr("selected", false)</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;">}</span><br style="font-family: courier new,monospace;"><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">jQuery.fn.toggleOption
= function() {</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">  return this.each(function() { this.selected = !this.selected; })</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;">}</span><br style="font-family: courier new,monospace;"><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">jQuery.fn.moveToSelect
= function(el) {</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">  jQuery(el).append(this);</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">
}</span><br style="font-family: courier new,monospace;"><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">jQuery.fn.jsAttr = function(attr, value) {</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;">  return this.each(function() { this[attr] = value })</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">}</span><br clear="all">
The above are a few utility functions I wrote so I could write a dual-pane select box implementation that moved from one box to another.
So you could do $("#first option:selected").moveToSelect("#second")
--
Yehuda Katz
Web Developer | Wycats Designs
(ph)  718.877.1325
_______________________________________________
jQuery mailing list
discuss@jquery.com
http://jquery.com/discuss/