Tags: jquery

Sort by: Date / Title /

  1. 1 year ago by minus
    1. $("input:visible:enabled:first").focus();
    Paste this in your website: <script type="text/javascript" src="http://www.posteet.com/embed/1335"></script>
  2. 1 year ago by cyo
    Code à placer à la fin du fichier jquery.js
    1. ;(function($) {
    2.  
    3. /**
    4. * Selects an option by text
    5. *
    6. * @name     selectOptionsByText
    7. * @author   Mathias Bank (http://www.mathias-bank.de), original function
    8. * @author   Sam Collett (http://www.texotela.co.uk), addition of regular expression matching
    9. * @author   Christophe (version modifiée : recherche sur le texte au lieu de rechercher sur la valeur du champ option)
    10. * @type     jQuery
    11. * @param    String|RegExp value  Which options should be selected
    12. * can be a string or regular expression
    13. * @param    Boolean clear  Clear existing selected options, default false
    14. * @example  $("#myselect").selectOptions("val1"); // with the text 'val1'
    15. * @example  $("#myselect").selectOptions(/^val/i); // with the text starting with 'val', case insensitive
    16. *
    17. */
    18. $.fn.selectOptionsByText = function(text, clear)
    19. {
    20.     var v = text;
    21.     var vT = typeof(text);
    22.     var c = clear || false;
    23.     // has to be a string or regular expression (object in IE, function in Firefox)
    24.     if(vT != "string" && vT != "function" && vT != "object") return this;
    25.     this.each(
    26.         function()
    27.         {
    28.             if(this.nodeName.toLowerCase() != "select") return this;
    29.             // get options
    30.             var o = this.options;
    31.             // get number of options
    32.             var oL = o.length;
    33.             for(var i = 0; i<oL; i++)
    34.             {
    35.                 if(v.constructor == RegExp)
    36.                 {
    37.                     if(o[i].text.match(v))
    38.                     {
    39.                         o[i].selected = true;
    40.                     }
    41.                     else if(c)
    42.                     {
    43.                         o[i].selected = false;
    44.                     }
    45.                 }
    46.                 else
    47.                 {
    48.                     if(o[i].text == v)
    49.                     {
    50.                         o[i].selected = true;
    51.                     }
    52.                     else if(c)
    53.                     {
    54.                         o[i].selected = false;
    55.                     }
    56.                 }
    57.             }
    58.         }
    59.     );
    60.     return this;
    61. };
    62.  
    63. })(jQuery);
    Paste this in your website: <script type="text/javascript" src="http://www.posteet.com/embed/1202"></script>
  3. 2 years ago by spirit
    1. $.create = function() {
    2.   var ret = [], a = arguments, i, e;
    3.   a = a[0].constructor == Array ? a[0] : a;
    4.   for(i=0; i<a.length; i++) {
    5.     if(a[i+1] && a[i+1].constructor == Object) { // item is element if attributes follow
    6.       e = document.createElement(a[i]);
    7.       $(e).attr(a[++i]); // apply attributes
    8.       if (a[i] == 'table') alert ('titi');
    9.       if(a[i+1] && a[i+1].constructor == Array) $(e).append($.create(a[++i])); // optional children
    10.       ret.push(e);
    11.     } else { // item is just a text node
    12.       ret.push(document.createTextNode(a[i]));
    13.     }
    14.   }
    15.  
    16.   return ret;
    17. };
    18.  
    19.  
    20. // Usage
    21. $.create(
    22.    'table', { 'class':"MyTable" }, [
    23.       'tbody', {}, [
    24.          'tr', { 'class':"MyTableRow" }, [
    25.             'td', { 'class':"MyTableCol1" }, [ "howdy" ],
    26.             'td', { 'class':"MyTableCol2" }, [
    27.                "Link:", 'a', { 'class':"MyLink", 'href':"http://www.example.com" }, ["example.com"] ] ],
    28.          'tr', { 'class':"MyTableRow2" }, [
    29.             'td', { 'class':"MyTableCol1" }, [ "howdy" ],
    30.             'td', { 'class':"MyTableCol2" }, [
    31.                "Link:", 'a', { 'class':"MyLink", 'href':"http://www.example.com" }, ["example.com"] ] ] ] ]);
    Paste this in your website: <script type="text/javascript" src="http://www.posteet.com/embed/115"></script>
  4. sponsorised links

First / Previous / Next / Last / Page 1 of 1 (3 posteets)