google+javascriptbanktwitter@js_bankfacebook@jsbankrss@jsbank
Guest, register






Efficient and Helpful JavaScript/jQuery Tips and Tricks This free HTML JavaScript tutorial provides 45+ JavaScript/jQuery tips and tricks that help you work in JavaScript tasks better, through live HTML JavaScript example codes. List of some JavaScript tips and tricks:

- Refreshing the src of an image with jQuery?
- Check if an image is loaded or not with jQuery
- Remove selected text after mouse double click JavaScript event
- Validate an email address
- Check if an HTML control element exists
- Cancel an AJAX request
- Select all HTML checkboxes
- Selecting root element of a certain level in the document
- Searching a string in jQuery

Please go to the full post page for full detailed tips and HTML JavaScript example codes, then try some JavaScript tutorials:

- 10 Small Javascript Tricks You Should Master
- Some Basic Tips and Tricks for Speeding Up JavaScript
- 10 jQuery and JavaScript Tips and Tricks to Improve Your Code
- 5 Good and Small JavaScript Tips and Tricks


Label: JavaScript event, HTML control, HTML JavaScript example code, 45

Free iPage Web Hosting for First Year NOW



If you're still looking for a reliable web host provider with affordable rates, why you don't take a little of time to try iPage, only with $1.89/month, included $500+ Free Extra Credits for the payment of 24 months ($45)?

Over 1,000,000+ existisng customers can not be wrong, definitely you're not, too! More important, when you register the web hosting at iPage through our link, we're going to be happy for resending a full refund to you. That's awesome! You should try iPage web hosting for FREE now! And contact us for anything you need to know about iPage.
Try iPage for FREE First Year NOW
  • 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);
    iPhoneKer.com
    Save up to 630$ when buy new iPhone 15

    GateIO.gomymobi.com
    Free Airdrops to Claim, Share Up to $150,000 per Project

    https://tooly.win
    Open tool hub for free to use by any one for every one with hundreds of tools

    chatGPTaz.com, chatGPT4.win, chatGPT2.fun, re-chatGPT.com
    Talk to ChatGPT by your mother language

    Dall-E-OpenAI.com
    Generate creative images automatically with AI

    AIVideo-App.com
    Render creative video automatically with AI

    JavaScript by day


    Google Safe Browsing McAfee SiteAdvisor Norton SafeWeb Dr.Web