I have this code:
<script>
$(document).ready(function () {
$(document).on('click', '.a_mod_t', function (e) {
e.preventDefault();
var id = $(this).attr('rel');
var data_d = 'id=' + id;
$.ajax({
type: "POST",
data: data_d,
cache: false,
url: "php/show_dec.php",
success: function (html) {
var obj = $.parseJSON(html);
$.each(obj, function (index, element) {
var id_trattamento = element.id_trattamento; // trattamento, id_tariffa, tip_dente, denti(txt)
var id_tariffa = element.id_tariffa;
var tip_dente = element.tip_dente;
var denti = element.denti;
var array = new Array();
var array2 = new Array();
var var_a = "#";
array = denti.split(',');
var arrayLength = array.length;
for (var i = 0; i < arrayLength; i++) {
// put the # inside the array
alert(array2[i]);
//Do something
}
alert(id_trattamento);
alert(id_tariffa);
alert(tip_dente);
alert(array[0]);
}); // fine .each
}, // fine success
error: function (xhr, status, error) {
console.log(status);
console.log(error);
console.dir(xhr);
} // fine error
}); // fine ajax
});
});
</script>
In this code I get a string text and then I split it and put it into an array. Everything is fine but I need to do another thing and I don't know how.. this array contains the splitted text so for example I have array[0] that contains the text "61". 61 is also the id of a checkbox that I need to change with jquery. but to do so I need to put a "#" in my array before every text. I need to know how I can obtain this -> array[0] = #61 .. or if there is a way to join the # symbols during the jquery command, something like:
$ '#' . ('array[0]').css(..);
$('#' + array[0]).css(...)