将变量从链接传递给 div [英] Pass variable from link to div

查看:34
本文介绍了将变量从链接传递给 div的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个通过链接进行的纯 css3 模态调用,我希望将一些变量传递给模态.

模态

 

<div class="modal-content"><div class="header">原因

<div class="copy">//内容

<div class="footer"><a href="?r=Register/UpdateReason&appid=">关闭</a></div><br/>

HTML

//其他一些带有foreach appid的代码<a href="#reasonmodal">点击</a>

我想将 foreach appid 传递给模态,有什么建议吗?谢谢

解决方案

我有一个想法(仅限 js):

<a href="#reasonmodal" class="modal-link" rel="<?=$app_id?>">点击</a><a href="#" id="submit-link">关闭</a>

和模态动作:

$(".modal-link").click(function(){$("#submit-link").attr('href','?r=Register/UpdateReason&appid='+$(this).attr('rel'));$($(this).attr('href')).modal('show');});

I have a pure css3 modal call by a link, and I wish to pass some variable to the modal.

Modal

    <div id="reasonmodal">
    <div class="modal-content">
        <div class="header">
            Reason
        </div>

        <div class="copy">
             //content
        </div>
        <div class="footer"><a href="?r=Register/UpdateReason&appid=">Close</a></div>
        <br />  

    </div>

HTML

    //some other code with foreach appid
    <a href="#reasonmodal">Click</a>

I want pass foreach appid to the modal, any suggestion to do that ? Thanks

解决方案

i have an idea (js only):

<a href="#reasonmodal" class="modal-link" rel="<?=$app_id?>" >Click</a>

<a href="#" id="submit-link">Close</a>

and modal action :

$(".modal-link").click(function(){
   $("#submit-link").attr('href','?r=Register/UpdateReason&appid='+$(this).attr('rel'));
   $($(this).attr('href')).modal('show');
});

这篇关于将变量从链接传递给 div的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
前端开发最新文章
热门教程
热门工具
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆