Caption for the datatable
Caption for the datatable
laxmipark
Posts: 22Questions: 8Answers: 0
$('#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.