Below is my jQuery Code, I have to change the attribute:
I have 2 list of similar items, i have to disable selected item of first in second list, and in first list i have prefix lstrYM with Item and in second list having prefix ltrY2 with item
I am very week in jquery , so i dont know how exact find, so i am runnig the loop
$('#lsltrYMaxis').change(function () {
var flg = 0;
$('#lsltrYMaxis option').each(function () {
var val = this.value;
val = val.replace("YMa", "Y2a"); // find y2 axis with similar index
var chk = $(this).is(':checked'); // checked
// alert(val);
// alert(chk);
$('#lsltrY2axis option').each(function () {
var val2 = this.value;
alert(val + ";" + val2 + ";" + chk);
if (val === val2) {
if (chk === true) {
alert((this).value);
$(this).attr({ 'disabled': true, 'aria-disabled': true, 'checked': false, 'aria-selected': false }).addClass('ui-state-disabled');
alert('done');
flg = 1;
return false;
}
else {
$(this).attr({ 'disabled': false, 'aria-disabled': false }).removeClass('ui-state-disabled');
flg = 1;
return false;
}
}
});
if (flg == 1)
return false;
});
});
But it says
(this).attr
is not a function
Its applying the attribute
What am I doing wrong?