Add JQUERY and CSS Header
<script src="Scripts/jquery-2.0.3.min.js"></script>
<script src="Scripts/jquery-ui-1.10.3.min.js"></script>
<script src="Scripts/configSetting.js"></script>
<link href="Content/themes/base/jquery-ui.css" rel="stylesheet" />
Way to find Javascript Class : $(".Config")
2 way to find Javascript ID :
- $("a[id*=InsertLink]")
- $("#InsertLink")
INPUT
|
Button | checkbox | hidden | image | radio | DateTime | Textbox
|
a
|
Link
|
SELECT
|
DropDown
|
JQUERY METHOD AND CODE
Click trigger
(
can use this in following as an
object)
|
$("INPUT[id*=SelectCheck]").click(function () { }
|
Change trigger
|
$("INPUT[id*=radStatus]").change(function () {
|
Check Box set
True (attr – before JQuery 1.6 / prop –
after JQuery 1.6)
|
$("INPUT[id*=SelectCheck]").prop("checked", true);
|
Set (true|false to
set disabled | enabled)
|
$("INPUT[id*= txtname]").removeAttr("disabled");
$("INPUT[id*=txtname]").attr("disabled", true);
|
Dropdown Select
Index
|
$("SELECT[id*=ddlCountry]")[0].selectedIndex
= 0;
|
Find and get
Value
|
var app = $(this).find(INPUT [type=hidden][id*=App]').val();
|
Get value
Get Checkbox /
radio value
|
$(this).val();
$("INPUT[id*=rbEffective]:checked").val();
|
Set Value
|
$(this).val("Inactive");
|
hide / show
|
$('#countryFieldSet').hide(); / .show();
|
Link URL
|
location.href
= Country.aspx';
|
Get
Table Column
|
var getNameCol = $("TABLE[id*=gvPeople] tr").find('th:nth-child(2)').text();
|
DropDown or
Text Change
|
$("INPUT[id*=txtName],SELECT[id*=ddlGender]").change(function ()
{
|
Parse Float
|
var price = parseFloat($("INPUT[id*=txtPrice]").val()); |
parseint
|
Change Image
|
$('#Image1').attr('src',
x);
|
Modal Popup
|
$('#myModal').modal('show');
|
Function with Param
|
function modalup(x,
y) { }
onclick='modalup("<%# Eval("ImageURL","studentImage/{0}") %>","<%# Eval("Age")%>");'>
|
Date Format
|
<script src="scripts/jquery.dateFormat-1.0.js"></script>
$.format.date(new Date, 'dd/M/yy
hh:mm:ss'));
|
Pass self and target to function
($this must at onclick)
|
<input type="checkbox" name="search_rule" onclick="ControlList($(this),'ListTransMatchedRule')" />
function ControlList(checkbox,
list) {
if (checkbox.is(':checked'))
{
$("#" +
list).attr("disabled", true);
$("#" +
list)[0].selectedIndex = -1;
}
else {
$("#" +
list).attr("disabled", false);
}
}
|
Foreach Tr with specific Class
|
$("Table[id=tblCust]
tr[class='content']").each(function (tr)
|
Get Attribute (Id, name, rowspan)
|
$(this).attr('id');
|
Split string
|
var rowArray = rowID.split("_");
|
Hide & Show
|
$(this).hide(); | show();
|
Hide Checking
|
if (tdDataType.is(':hidden'))
|
Insert | add td to tr (this is TR)
|
tdData.prependTo($(this)); | tdData.appendTo($(this));
|
Find (like) start from | eq(0)
is first item
|
$("Table[id=tblCust]").find("tr[id^='" + prow + "']").eq(0);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|