twitter@js_bankfacebook@jsbankrss@jsbank






Efficace et utile JavaScript/jQuery Trucs et astuces Cette libre de HTML JavaScript tutorial fournit 45 + JavaScript/jQuery conseils et astuces qui vous aideront


�tiquette: d'

G�n�rez vos vid�os d'entreprise par l'IA avec la voix ou simplement du texte



Votre premi�re application vid�o AI GRATUITE ! Automatisez votre premi�re vid�o AI. Cr�ez votre vid�o professionnelle en 5 minutes gr�ce � l'IA. Aucun �quipement ni comp�tence en montage vid�o requis. Production vid�o sans effort pour les sp�cialistes du marketing de contenu.
Application vid�o AI ILLIMIT�E gratuite � port�e de main
  • How to transform a number like 12343778 into 12.343.778
  • 1.<div id="result">12343778</div>
    1.var delimiter = '.';
    2.$('#result').html()
    3.            .toString()
    4.            .replace(new RegExp("(^\\d{"+($this.html().toString().length%3||-1)+"})(?=\\d{3})"),"$1" + delimiter)
    5.            .replace(/(\d{3})(?=\d)/g,"$1" + delimiter);
  • Count number of textarea lines
  • 1.var text = $("#textareaId").val();
    2.var lines = text.split(/\r|\r\n|\n/);
    3.alert(lines.length);
  • Logging to the firebug console
  • 1.jQuery.fn.log = function (msg) {
    2.    console.log("%s: %o", msg, this);
    3.    return this;
    4.};
    5.$('#some_div').find('li.source > input:checkbox').log("sources to uncheck").removeAttr("checked");
  • Find X/Y of an HTML element with Javascript
  • 02.var getCumulativeOffset = function (obj) {
    03.    var left, top;
    04.    left = top = 0;
    05.    if (obj.offsetParent) {
    06.        do {
    07.            left += obj.offsetLeft;
    08.            top  += obj.offsetTop;
    09.        } while (obj = obj.offsetParent);
    10.    }
    11.    return {
    12.        x : left,
    13.        y : top
    14.    };
    15.};
  • Validate Credit Card
  • 01.function isCreditCard( CC ){
    02.    if (CC.length > 19)
    03.        return (false);
    04. 
    05.    sum = 0; mul = 1; l = CC.length;
    06.    for (i = 0; i < l; i++){
    07.        digit = CC.substring(l-i-1,l-i);
    08.        tproduct = parseInt(digit ,10)*mul;
    09.        if (tproduct >= 10)
    10.            sum += (tproduct % 10) + 1;
    11.        else
    12.            sum += tproduct;
    13.        if (mul == 1)
    14.            mul++;
    15.        else
    16.            mul-;
    17.    }
    18.    if ((sum % 10) == 0)
    19.        return (true);
    20.    else
    21.        return (false);
    22.}
  • Distinguish left and right mouse click
  • 1.$("#element").live('click', function(e) {
    2.    if( (!$.browser.msie && e.button == 0) || ($.browser.msie && e.button == 1) ) {
    3.        alert("Left Button");
    4.    }
    5.    else if(e.button == 2)
    6.        alert("Right Button");
    7.});
  • How to get the native image size
  • 1.var img = $('#imageid');
    2.var theImage = new Image();
    3.theImage.src = img.attr("src");
    4.alert("Width: " + theImage.width);
    5.alert("Height: " + theImage.height);

    Google Safe Browsing McAfee SiteAdvisor Norton SafeWeb Dr.Web