jQuery: this.attr() not a function?
Use: $(this).attr instead of this.attr This forces it into the context of jQuery.
Use: $(this).attr instead of this.attr This forces it into the context of 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
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>
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
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
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
Give zero to mindate and it’ll disabale past dates. $( “#datepicker” ).datepicker({ minDate: 0}); here is a Live fiddle working example http://jsfiddle.net/mayooresan/ZL2Bc/ The official documentation is available here
This should do it I think $(“#formId input:text, #formId textarea”).first().focus();
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
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