I have a HTML element with an ID: containerButtons for which have a number of labels and div:
<div class="button-grp" id="containerButtons">
<label>Selector 1</label>
<label>Selector 2</label>
<label>Selector 3</label>
<div class="time-container">
<input type="number" min="0" max="24" step="1" value="00" id="time-hour" disabled="disabled">
<span>:</span>
<input type="number" min="0" max="60" step="1" value="00" id="time-minutes" disabled="disabled">
</div>
</div>
The above is created through a JS function in file, buttons.js.
buttons.js:
function ButtonsPanel() {
var that = this;
this.buttonsEl = document.createElement('div');
var baseBtn = d3.select(this.buttonsEl);
var containerBtns = baseFilter.append('div')
.classed({'button-grp': true})
.attr({id:'containerButtons'});
var tmp = containerBtns.append('div')
.classed({'time-container': true});
tmp.append('input')
.attr({type: 'number', min: '0', max: '24', step:'1', value:'00', id:'time-hour', 'disabled': 'disabled'});
tmp.append('span')
.text(':');
tmp.append('input')
.attr({type: 'number', min: '0', max: '60', step:'1', value:'00', id:'time-minutes', 'disabled': 'disabled'});
this.timeInputs = tmp;
var timeHours = this.timeInputs[0][0].children[0];
// returns <input type="number" min="0" max="24" step="1" value="00" id="time-hour" disabled="disabled">
var timeMins = this.timeInputs[0][0].children[2];
// returns <input type="number" min="0" max="60" step="1" value="00" id="time-minutes" disabled="disabled">
}
Within buttons.js, i have a method which is called on load toggleVisability:
ButtonsPanel.prototype.toggleVisability = function() {
var that = this;
this.visabilityApply('#containerButtons', function(num) {
if (!num) {
alert(that.timeInputs[0][0].children[0]);
that.timeInputs[0][0].children[0].attr({'disabled': true});
}
else {
alert(that.timeInputs[0][0].children[0]);
that.timeInputs[0][0].children[0].attr({'disabled': null});
}
});
};
With the above, i get error:
TypeError: that.timeInputs[0][0].children[0].attr is not a function
Yet, if i apply:
that.timeInputs.attr({'disabled': true});
The above works fine, however, i want to toggle the disabled attributes on the input fields. I am using jQuery.