« Posts under 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.

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

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

JavaScript

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");