how can I access javascript variables in blade laravel?
for example
var counter = 1;
{{ dd(counter) }}
it gives me this error
Use of undefined constant counter – assumed ‘counter’ (this will throw
an Error in a future version of PHP)
how can I access javascript variables in blade laravel?
for example
var counter = 1;
{{ dd(counter) }}
it gives me this error
Use of undefined constant counter – assumed ‘counter’ (this will throw
an Error in a future version of PHP)
2
Answers
You can’t. You need to use JavaScript to inject the values to the Blade templates. Basically you need to do this in a
script
tag.Its better to add any id where you want to show veriable then select this element using query selector
and use jquery