$(”) vs $(”) in jQuery

There is no difference, as seen in the source code, line 30 & line 121: /* Line 30*/ rsingleTag = /^<(\w+)\s*\/?>(?:<\/\1>)?$/, /* Line 121 */ // If a single string is passed in and it’s a single tag // just do a createElement and skip the rest ret = rsingleTag.exec( selector ); The following are … Read more

Jquery – Perform callback after append

jQuery’s .each() takes a callback function and applies it to each element in the jQuery object. Imagine something like this: $(‘a.ui-icon-cart’).click(function(){ $(this).closest(‘li’).clone().appendTo(‘#cart ul’).each(function() { $(this).find(‘h5’).remove(); $(this).find(‘img’).css({‘height’:’40px’, ‘width’:’40px’}); $(this).find(‘li’).css({‘height’:’60px’, ‘width’:’40px’}); }); }); You could also just store the result and work on it instead: $(‘a.ui-icon-cart’).click(function(){ var $new = $(this).closest(‘li’).clone().appendTo(‘#cart ul’) $new.find(‘h5’).remove(); $new.find(‘img’).css({‘height’:’40px’, ‘width’:’40px’}); $new.find(‘li’).css({‘height’:’60px’, ‘width’:’40px’}); }); … Read more

jQuery: loading css on demand + callback if done

How to load multiple CSS files with callback as requested Note: ithout xdomain permissions, $.get will only load local files WORKING DEMO Note that the text “all css loaded” appears after loading but before the CSS is applied. Perhaps another workaround is required to overcome that. $.extend({ getManyCss: function(urls, callback, nocache){ if (typeof nocache==’undefined’) nocache=false; … Read more

jquery .on() method with load event

Refer to http://api.jquery.com/on/ It says In all browsers, the load, scroll, and error events (e.g., on an <img> element) do not bubble. In Internet Explorer 8 and lower, the paste and reset events do not bubble. Such events are not supported for use with delegation, but they can be used when the event handler is … Read more

How to dynamically add a new column to an HTML table

I updated your fiddle with a small example how you could do that. jsFiddle – Link var myform = $(‘#myform’), iter = 0; $(‘#btnAddCol’).click(function () { myform.find(‘tr’).each(function(){ var trow = $(this); if(trow.index() === 0){ trow.append(‘<td>Col+’iter+'</td>’); }else{ trow.append(‘<td><input type=”checkbox” name=”cb’+iter+'”/></td>’); } }); iter += 1; }); This would add a new column to every row, including … Read more

Custom sorting on values in a data-sort attribute with Jquery Datatables

You can use data-order attr, for example <table class=”table table-bordered table-hover”> <thead> <tr> <th>Date</th> <th>Count</th> </tr> </thead> <tbody> <?php $count = 0; foreach($users as $user) {?> <tr> <td data-order=”<?php echo $count ?>”> <?php echo $user[‘createdDate’]; ?> </td> <td> <?php echo $user[‘count’]; ?> </td> </tr> <?php $count++; }?> <tr> <td data-order=”999999999999999999999999999″> <!–always last–> Total </td> <td> … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)