javascript - Pass html element value to laravel Blade IF
问题描述
i need help how to pass &{currentQuestion.id_soal} to laravel if, example:
@if($s->id == &{currentQuestion.id_soal} )
this is the script:
output.push(
`<div class="slide">
@foreach ($soal as $key => $s)
@php
$ids = ${currentQuestion.id_soal}
@if($s->id == $ids )
<p>{!!$s->soal!!}</p>
@endif
@endphp
@endforeach
<img src="{{ asset('/soal_gambar${currentQuestion.gambar}')}}" style="max-width: 100%;" onerror="this.style.display='none'"/>
<div class="answers"> ${answers.join("")} </div>
</div>`
);
解决方案
使用这个{!! $data !!}
,它显示内容而不转义 HTML 特殊字符。
推荐阅读
- java - 如何在 FTL(Freemarker) 中访问列表的映射
- python - 如何根据开始和结束字符Python获取列表的子集
- database - 将查询计数存储在 vb 变量中
- ruby-on-rails - 尝试解析 XLS 文件时出现“OLE2 签名无效”
- maven - sonarqube gitlab插件可以只扫描更改的文件吗
- python - 在 PyMongo 中查询一个数组
- javascript - java脚本中的全局变量将值从函数内部传递到函数外部
- node.js - Firebase Admin Node.js 读/写数据库
- javascript - Gatsby.js 的 GraphQL 查询回调
- html - 如何用 CSS 创建这个按钮?