$('input[name=type]').change(function () { alert($(this).val()); }); $('input[value=SV]').attr('checked', 'checked').trigger('change'); });
world wide web development problems asp net php html xhtml css javascript jquery w3dproblems
Showing posts with label JavaScript. Show all posts
Showing posts with label JavaScript. Show all posts
Monday, September 8, 2014
call change() event handler if I select radio button programatically
$(function () {
Sunday, November 3, 2013
Change an Image while using JCrop
Initialize jCrop
var jcrop_api; function InitjCrop() { $('#id').Jcrop({ }, function () { jcrop_api = this; }); }To unhook jCrop
jcrop_api.destroy();To Hook jCrop again
InitjCrop();
Tuesday, October 8, 2013
Inserting text after cursor position in text areа
$.fn.extend({
insertAtCaret: function (myValue) {
if (!this.selectionStart)
thi = $(this).get(0);
if (thi.selectionStart || thi.selectionStart == '0') {
var startPos = thi.selectionStart;
var endPos = thi.selectionEnd;
var scrollTop = thi.scrollTop;
thi.value = thi.value.substring(0, startPos) + myValue + thi.value.substring(endPos, thi.value.length);
thi.focus();
thi.selectionStart = startPos + myValue.length;
thi.selectionEnd = startPos + myValue.length;
thi.scrollTop = scrollTop;
} else {
thi.value += myValue;
thi.focus();
}
}
})
Convert jQuery object to DOM object
jQuery Object
$('textarea')
example of setting a value
$('textarea').val("Hi");
DOM object
$('textarea').get(0)
example of setting a value
$('textarea').get(0).value = "Hi";
Monday, August 26, 2013
jQuery how to check html input checkbox state
$("input[type=checkbox]").change(function () { var isChecked = this.checked; if (isChecked) { //rest goes here } });
Saturday, July 7, 2012
JavaScript URL encode
encodeURIComponent(str);
jQuery get specific option tag text
$("#list
option:selected").text();
Friday, March 30, 2012
How to check whether an DOM element exists using JQuery(JS)
If you every want to check whether an element exists using JavaScript
or jQuery, just use this snippet
if
( $("selector").length
) {
// rest goes here
}
// rest goes here
}
Friday, December 3, 2010
Parsing UK Date in javascript
To reach a date object with UK format in javascript has no straight road. Well you can use split map to reach there.
Consider this example
var ukDate = new Date("01/12/2011");
well for javascript it is
Wed Jan 12 2011 00:00:00
but we can use the split() object to first separate the date using “/” as separator and then create the Date Object
Consider this example
Thu Dec 01 2011
and your are done
Consider this example
var ukDate = new Date("01/12/2011");
well for javascript it is
Wed Jan 12 2011 00:00:00
but we can use the split() object to first separate the date using “/” as separator and then create the Date Object
Consider this example
var ukDate="01/12/2011";
var dateArray=ukDate.split("/");
var newDate=new Date(dateArray[2], dateArray[1]-1,dateArray[0]);
not output will be
Thu Dec 01 2011
and your are done
Subscribe to:
Comments (Atom)