Category: jquery

  • DataTable jQuery Plugin – JavaScript inside a table cell

    If the data source is AJAX and the cell has JavaScript, the node is created and assigned directly via nTd.innerHTML=data so any JavaScript code inside the cell won’t get executed. To correct than you need the custom fnRender for that column. fnRender: function (o) { var oTmp = document.createElement(“div”); oTmp.innerHTML = o.aData[5]; // just to…

  • jQuery form item highlighting

    $(document).ready(function(){ $(“input,textarea,select”) .focus(function() {$(this).addClass(“form-item-focus”);}) .blur(function() {$(this).removeClass(“form-item-focus”);}); });

  • Debugging jQuery selector

    Selectors are really powerful, but how to you know what/which elements were chosen? Use this statement var str = $(e).parents(“form tr”).map(function() { return this.tagName; }).get().join(“, “); alert(str);

  • jQuery.com down or super slow

    Anyone knows a downloadable documentation for jQuery. Their site is so slow that makes referencing impossible. This is an recurring issue that has happened for quite a few months. Is the traffic too much for them to handle?

  • jQuery not selecting nested elements

    For a jQuery newbie, I was unsure how to only select the TR’s of the main table and not TR’s within sub-tables. Tried this that (children(), siblings()) and a bunch of selectors and found out the easy way (‘#mytable > tbody > tr’) How easy! 🙂

  • Check username availability via AJAX with jQuery

    HTML Checking… JavaScript $(“#loading”).hide(); var orig=$(“#loading”).html(); $(“#UserNameInputID”).blur(function() { $(“#loading”).html(orig); $(“#loading”).show(); loadTextPage(“loading”,”check.php?username=”+$(“#UserNameInputID”).val()); }); /** load a text page into this div */ function loadTextPage($pDivID,$pURL) { $.ajax({ url:$pURL, dataType:’html’, success:function (txt) { $(‘#’+$pDivID).html(txt); } }); Server-side check.php

  • jQuery eq() typical mistake

    With all the open/close quote, you might write this code: var i = 123; $(“:checkbox:eq(i)”).removeAttr(“disabled”); Since the selector string is within the quotes, the correct statement should be: $(“:checkbox:eq(“+i+”)”).removeAttr(“disabled”);