Check if a class `active` exist on element with jquery
I think you want to use hasClass() $(‘li.menu’).hasClass(‘active’);
I think you want to use hasClass() $(‘li.menu’).hasClass(‘active’);
The keyup event fires after the default behaviour (populating text area) has occurred. It’s better to use the keypress event, and filter non-printable characters. Demo: http://jsfiddle.net/3uhNP/1/ (with max length 4) jQuery(document).ready(function($) { var max = 400; $(‘textarea.max’).keypress(function(e) { if (e.which < 0x20) { // e.which < 0x20, then it’s not a printable character // e.which … Read more
In the current version of DataTables (1.10.4) you can simply add destroy:true to the configuration to make sure any table already present is removed before being re-initialised. $(‘#example’).dataTable({ destroy: true, aaData: response.data });
Here’s a hopefully bug-free version, updating as you drag. It’s generating the current desired positions of the items when sorting starts, which means you should be able to change the classes whenever you need, refresh the widget’s list items and you’re good to go. It also uses the sortable’s built-in items property to prevent dragging … Read more
It’s the same as in CSS selectors: $(‘.headsection, .subtitle’);
You can use .eq() with a negative value (-1 is last) to get n from the end, like this: $(“.album li”).eq(-2).attr(“id”); // gets “li-9” You can test it here.
*Update: * Please take a note of @mathoiland’s answer, “It looks like Fancybox 2 deprecated the onClosed callback. It now uses afterClose.” if you are using FancyBox 2.x Pass the onClosed option to the fancybox function. i.e: $(“<YOUR-SELECTOR>”).fancybox({ onClosed: function() { $(‘#sub_cont’).hide(250, function() { $(‘#IDsearchform input’).val(”); }); }) });
The problem is very simple. First let’s set up the scenario. You have a list of sortable elements, your page is higher than your screen so it has a scrollbar, your page is at the very bottom, the scroll bar all the way down. The issue, you go to drag an element which causes jQuery … Read more
Your problem may be happening because you are assigning the same handler to the click event multiple times. I suggest you check that the line where you assign the handler is not being called multiple times inadvertently. Another solution could be a call to unbind (deprecated 3.0) or off (superseeded) first: $(“#myButton”).unbind(“click”).click(myHandler); // deprecated $(“#myButton”).off(“click”).click(myHandler); … Read more
Its the first time MS is shipping an open source component they didn’t write with one of their products. This doesn’t seem like a big deal, but its almost nuclear in its implications. Think about it… They are saying “we support this.” In an OSS product, MS has no control over the code. So, they … Read more