Good day! I want to increment a subscript in a div it name, like "#jstree1"
, "#jstree2"
... etc. I know iterations and incrementing values are a solution. But with this kind of structure, I can't figure out how.
<script src= '@routes.Assets.at("dist/libs/jquery.js")' type="text/javascript"></script>
<script src= '@routes.Assets.at("dist/jstree.min.js")' type="text/javascript"></script>
<script>
$(function () {
var i = 0;
// 6 create an instance when the DOM is ready
$('#jstree'+i).jstree({
"core" : {
"animation" : 0,
"check_callback" : true,
"themes" : { "stripes" : true }
},
/*"plugins" : [
"search", "unique",
"state", "types"
]*/
"plugins" : [
"contextmenu", "dnd", "search",
"state", "types", "core", "json_data", "ui", "crrm"
]
});
i++;
var to = false;
var k = 0;
$('#plugins4_q').keyup(function () {
if(to) { clearTimeout(to); }
to = setTimeout(function () {
var v = $('#plugins4_q').val();
$('#jstree'+k).jstree(true).search(v);
}, 250);
});
k++;
});
</script>
}
I need to increment the div
jstree
for displaying the tree and making the search bar to work but it doesn't work. So I'm thinking to assign the variable to any number, if possible. Please help me fix this. Thank you very much.