Array to Comma separated string and for last tag use the ‘and’ instead of comma in jquery

You can use .slice(): > var a = [1, 2, 3, 4, 5]; > [a.slice(0, -1).join(‘, ‘), a.slice(-1)[0]].join(a.length < 2 ? ” : ‘ and ‘); ‘1, 2, 3, 4 and 5’ a.slice(0, -1).join(‘, ‘): takes all but the last element and joins them together with a comma. a.slice(-1)[0]: it’s the last element. .join(a.length < … Read more

Stop all playing iframe videos on click a link javascript

Try this way, <script language=”javascript” type=”text/javascript” src=”https://stackoverflow.com/questions/13598423/jquery-1.8.2.js”></script> <script language=”javascript” type=”text/javascript”> $(function(){ $(‘.close’).click(function(){ $(‘iframe’).attr(‘src’, $(‘iframe’).attr(‘src’)); }); }); </script>

how to add paragraph on top of div content

You may use prepend to add the paragraph at the top of the container: // HTML: <div><p>Lorem ipsum</p></div> $(‘div’).prepend(‘<p>Bla bla bla’); Update: Regarding your comment about how to fade in the paragraph – use fadeIn: $(“#pcontainer”).prepend($(‘<p>This paragraph was added by jQuery.</p>’).fadeIn(‘slow’)); A working demo: http://jsbin.com/uneso

How to make past date unselectable in fullcalendar?

I have done this in my fullcalendar and it’s working perfectly. you can add this code in your select function. select: function(start, end, allDay) { var check = $.fullCalendar.formatDate(start,’yyyy-MM-dd’); var today = $.fullCalendar.formatDate(new Date(),’yyyy-MM-dd’); if(check < today) { // Previous Day. show message if you want otherwise do nothing. // So it will be unselectable … Read more

Detecting data changes in forms using jQuery

You could bind the Change event for all inputs and flag a variable as true. Like this. var somethingChanged = false; $(document).ready(function() { $(‘input’).change(function() { somethingChanged = true; }); }); But, keep in mind that if the user changes something, then changes back to the original values, it will still be flagged as changed. UPDATE: … Read more

How do I assemble a using jQuery append()?

Nope, you can’t use it like that. append is an atomic operation, which creates the element directly. // The <ul> element is added to #details, then it is selected and the jQuery // selection is put in the “list” variable. var list = $(‘<ul/>’).appendTo(‘#details’); for (var i = 0; i < 10; i++) { // … Read more

Toggle between two classes in jQuery

How about $(YOUR_ELEMENT).live(“EVENT_NAME”, function() { $(“.portlet-header”).toggleClass(“ui-icon-plus”).toggleClass(“ui-icon-minus”); }); Even more shorter $(YOUR_ELEMENT).live(“EVENT_NAME”, function() { $(“.portlet-header”).toggleClass(“ui-icon-plus ui-icon-minus”); }); EDIT As of jQuery 1.7, the .live() method is deprecated. Use .on() to attach event handlers. Users of older versions of jQuery should use .delegate() in preference to .live(). jQuery API reference

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