简体   繁体   English

将 id 传递给模态中的标签 href(引导程序)

[英]pass id to a tag href in modal(bootstrap)

hy, i want to pass my id to a tag href in my modal(bootstrap), for know i using this to past my id from my modal button: hy,我想将我的 id 传递给我的模态(引导程序)中的标签 href,因为我知道我使用它从我的模态按钮过去我的 id:

        modal.find('#down').attr('href', function(i, href) {
            return href + div.data('id');
        });

this is my a tag:这是我的标签:

  <a type="button" id="down" href="<?php echo base_url(); ?>/aprove/download/">Berkas</a>

this is my modal button:这是我的模态按钮:

<a href="javascript:;" title="Lihat" data-id="<?php echo $q->id_project ?>"  data-toggle="modal" data-target="#lihat-data">                                                        <button data-toggle="modal" data-target="#ubah-data" class="btn btn-secondary"><i class="far fa-eye"></i></i></button>                                                  </a>

the problem its, every time i click the modal button, my a tag(href) will add previous id to the new one, like this:问题在于,每次我单击模态按钮时,我的 a tag(href) 都会将以前的 id 添加到新的 id 中,如下所示:

first modal:第一个模态:

href="http://localhost/pe//aprove/download/4"

second modal:第二种模式:

href="http://localhost/pe//aprove/download/41"

i need to refresh the table to make it just get their own id我需要刷新表格以使其获得自己的 ID

So do something like所以做类似的事情

<a type="button" id="down" data-href="<?php echo base_url(); ?>/aprove/download/">Berkas</a>

and read the data attribute并读取数据属性

var anchor = modal.find('#down')
anchor.attr('href', anchor.data('href') + div.data('id'));

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM