javascript - 如何将动态值从 html 按钮传递到模型

标签 javascript jquery html

请任何人知道我如何使用此按钮将值动态传递给模型...意思是..我有动态值要传递给此模型...我该怎么做...

//this is the button
<p> <button type="button" data-target="#exampleFormModal" data-toggle="modal"> Load</button> </p>

//from here is the model
<div id="exampleFormModal" aria-hidden="false" aria-labelledby="exampleFormModalLabel"
          role="dialog" tabindex="-1">

            <div class="modal-dialog">
</div>

</div>

最佳答案

我知道了......以防任何可能需要它的人..

我只是将变量(在本例中为 laravel 变量)传递到模型 ID 中,如下所示 id="exampleFormModal{{ $item->id}}"

//BUTTON..check the id
<p> <button type="button" class=" btn-block btn btn-direction btn-bottom btn-success btn-outline"  data-target="#exampleFormModal{{ $item->id}}" data-toggle="modal"> Load Truck</button> </p>


//Model ..check the ID
 <div class="modal fade" id="exampleFormModal{{ $item->id}}" aria-hidden="false" aria-labelledby="exampleFormModalLabel"
          role="dialog" tabindex="-1">

关于javascript - 如何将动态值从 html 按钮传递到模型,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59651129/

相关文章:

javascript - 验证文本区域的每一行都以某物开头

html - 无方案 URL 在 HTTP 中有效吗?

javascript - 使用javascript为选择框动态创建选项

javascript - 部分 JQuery 库,针对每个项目需求量身定制?

javascript - 从证书 x509 中提取公钥

javascript - Google Maps Javascript API v3 map 显示在桌面浏览器上,但不会显示在移动浏览器上

javascript - 单击更改颜色输入字段

javascript - 我如何使用回车键来提交用户名和密码

javascript - 以编程方式在 dijit 布局 TitlePane 中插入 dijit 内容 Pane

javascript - MongoDB 对单个文档的并发读/写