How to change the text of a button in jQuery?

Depends on what type of button you are using <input type=”button” value=”Add” id=’btnAddProfile’> $(“#btnAddProfile”).attr(‘value’, ‘Save’); //versions older than 1.6 <input type=”button” value=”Add” id=’btnAddProfile’> $(“#btnAddProfile”).prop(‘value’, ‘Save’); //versions newer than 1.6 <!– Different button types–> <button id=’btnAddProfile’ type=”button”>Add</button> $(“#btnAddProfile”).html(‘Save’); Your button could also be a link. You’ll need to post some HTML for a more specific answer. … Read more

MVC4 StyleBundle not resolving images

According to this thread on MVC4 css bundling and image references, if you define your bundle as: bundles.Add(new StyleBundle(“~/Content/css/jquery-ui/bundle”) .Include(“~/Content/css/jquery-ui/*.css”)); Where you define the bundle on the same path as the source files that made up the bundle, the relative image paths will still work. The last part of the bundle path is really the … Read more

jQuery Date Picker – disable past dates

You must create a new date object and set it as minDate when you initialize the datepickers <label for=”from”>From</label> <input type=”text” id=”from” name=”from”/> <label for=”to”>to</label> <input type=”text” id=”to” name=”to”/> var dateToday = new Date(); var dates = $(“#from, #to”).datepicker({ defaultDate: “+1w”, changeMonth: true, numberOfMonths: 3, minDate: dateToday, onSelect: function(selectedDate) { var option = this.id == … Read more

How to get HTML 5 input type=”date” working in Firefox and/or IE 10

You can try webshims, which is available on cdn + only loads the polyfill, if it is needed. Here is a demo with CDN: http://jsfiddle.net/trixta/BMEc9/ <!– cdn for modernizr, if you haven’t included it already –> <script src=”http://cdn.jsdelivr.net/webshim/1.12.4/extras/modernizr-custom.js”></script> <!– polyfiller file to detect and load polyfills –> <script src=”http://cdn.jsdelivr.net/webshim/1.12.4/polyfiller.js”></script> <script> webshims.setOptions(‘waitReady’, false); webshims.setOptions(‘forms-ext’, {types: ‘date’}); … Read more

How to reload current page without losing any form data?

You can use various local storage mechanisms to store this data in the browser such as Web Storage, IndexedDB, WebSQL (deprecated) and File API (deprecated and only available in Chrome) (and UserData with IE). The simplest and most widely supported is WebStorage where you have persistent storage (localStorage) or session based (sessionStorage) which is in … Read more

How to use radio on change event?

You can use this which refers to the current input element. $(‘input[type=radio][name=bedStatus]’).change(function() { if (this.value == ‘allot’) { alert(“Allot Thai Gayo Bhai”); } else if (this.value == ‘transfer’) { alert(“Transfer Thai Gayo”); } }); http://jsfiddle.net/4gZAT/ Note that you are comparing the value against allot in both if statements and :radio selector is deprecated. In case … Read more

Downloading jQuery UI CSS from Google’s CDN

The Google AJAX Libraries API, which includes jQuery UI (currently v1.10.3), also includes popular themes as per the jQuery UI blog: Google Ajax Libraries API (CDN) Uncompressed: http://ajax.googleapis.com/ajax/libs/jqueryui/1.10.3/jquery-ui.js Compressed: http://ajax.googleapis.com/ajax/libs/jqueryui/1.10.3/jquery-ui.min.js Themes Uncompressed: black-tie, blitzer, cupertino, dark-hive, dot-luv, eggplant, excite-bike, flick, hot-sneaks, humanity, le-frog, mint-choc, overcast,pepper-grinder, redmond, smoothness, south-street, start, sunny, swanky-purse, trontastic, ui-darkness, ui-lightness, and … Read more