I have a jsfiddle.
Here is an intput tag:
<div class="marging">
<input id="ex19" type="text" data-provide="slider"
data-slider-ticks = "[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12]"
data-slider-ticks-labels = '["Enero", "Febrero", "Marzo", "Abril", "Mayo", "Junio", "Julio", "Agosto", "Septiembre", "Octubre", "Noviembre", "Diciembre"]' />
</div>
<br/>
<br/>
<button id="myButton">
OKAY
</button>
When I click on the button I want to add the following attributes and also update the two that are already:
'data-slider-min':"1",
'data-slider-max':"3",
'data-slider-step':"1",
'data-slider-value':"3",
'data-slider-tooltip':"hide"
I have this javascript that works partially.
var spanishLabels = ["Enero", "Febrero", "Marzo"];
var num = [1,2,3];
$('#myButton').click(function() {
$('.data-slider-ticks-labels').each(function(index) {
$(this).text(spanishLabels[index]);
});
$('.data-slider-ticks').each(function(index) {
$(this).text(num[index]);
});
$( "#ex19" ).attr({
'data-slider-min':"1",
'data-slider-max':"3",
'data-slider-step':"1",
'data-slider-value':"3",
'data-slider-tooltip':"hide"
});
});
What am I doing wrong, why the JS does not work at all well.