This function will support all of the jquery properties. By using this function we will get fullId including master page user control, etc.
- function fxj$(Id)
- {
- if (Id != null)
- {
- var Control, ControlId, FinalId = '';
- var Ids = Id.replace(/^\s+|\s+$/g, "").split(/\s*,\s*/g);
- if (Ids[0].indexOf(" ") > -1)
- {
- Ids = Ids[0].split(" ");
- if (Ids.length == 2)
- {
- Control = Ids[0];
- if (Control.charAt(0) == '.') return $(Control + ' ' + Ids[1]);
- else
- {
- ControlId = $("[id$=" + Control + "]").attr('id');
- return $('#' + ControlId + ' ' + Ids[1]);
- }
- }
- }
- else
- {
- for (var i = 0; i < Ids.length; i++)
- {
- Control = Ids[i];
- if (Control.charAt(0) == '.')
- {
- FinalId += Control + ',';
- }
- else
- {
- var sCount = $("[id$=" + Control + "]").size();
-
- if (sCount > 1)
- {
- for (var j = 0; j < sCount; j++)
- {
- var sId = $($("[id$=" + Control + "]")[j]).attr('id');
- var sSplit = sId.split('_');
- var sOriginal = sSplit[sSplit.length - 1];
- if (sOriginal == Control)
- {
- Control = sId;
- break;
- }
- }
- }
- ControlId = $("[id$=" + Control + "]").attr('id');
- FinalId += '#' + ControlId + ',';
- }
- }
- FinalId = FinalId.substring(0, FinalId.length - 1);
- return $(FinalId);
- }
- }
- }
Usage of this function: - For disabling inside the div controls,
- $('#divchargecode input,select,textarea').attr("disabled", true);
- For giving multiple properties at a time,
- fxj$('IsFoc').prop(
- {
- 'checked': false,
- "disabled": true
- });
- For hiding buttons,
- showing buttons,
- perform jquery click event,
- Applying css,
- fxj$('IsFoc').css(
- {
- "border": "none",
- "box-shadow": "none"
- });
- Adding class,
- fxj$('IsFoc').addClass('hide');