Caption for the datatable
Caption for the datatable
![laxmipark](https://secure.gravatar.com/avatar/1a631e35a6f9b44d9696b2fcd4efd2cc/?default=https%3A%2F%2Fvanillicon.com%2F1a631e35a6f9b44d9696b2fcd4efd2cc_200.png&rating=g&size=120)
$('#jquery_table').append('<caption style="caption-side: top-right">2017- Analysis</caption>');
This is how I have set now. I would like to set the caption dynamic. Can I do it using variable?
This question has accepted answers - jump to:
This discussion has been closed.
Answers
I don't really understand what you mean I'm afraid. If you want to use a variable for the content you would do something like:
Allan
I would like to have caption for the Datatable grid displayed. I would like that be dynamic
How would I do that.
Hi Allan, I don't see you any content in your answer
Allan's answer shows how to use a variable. This is standard Javascript syntax. Just to add to his code:
Kevin
I'm still not really understanding your question to be honest. Why not just add a
caption
element? Example: http://live.datatables.net/yufiyiko/1/edit .Allan
How do you use the variable in the append syntax of the data table
var myvar = "This is dynamic data"
$('#jquery_table').append('<caption style="caption-side: top-right"> myvar</caption>');
Take a close look at the differences in the string you have versus the one Allan provided:
Allan's:
'<caption style="caption-side: top-right">'+myVar+'</caption>'
Yours:
'<caption style="caption-side: top-right"> myvar</caption>'
Allan's is multiple strings added together using
+
:'<caption style="caption-side: top-right">'
+myVar+
'</caption>'
If this is unclear then please see the "JavaScript String Operators" section of this doc:
https://www.w3schools.com/js/js_operators.asp
Kevin
Thanks Kevin.
I got it.