gpt4 book ai didi

html - 在 Codeigniter 中单击按钮时从数据库添加卡片元素

转载 作者:太空宇宙 更新时间:2023-11-04 07:55:03 24 4
gpt4 key购买 nike

假设我有一个空白页面和一个按钮(位于右上角某处),以及一个 MySQL 数据库。

当我单击该按钮时,我希望能够在页面(名片)上创建一个方 block ,其中包含来自 MySQL 的数据库中的内容。

当我再次点击它时,我希望能够在它旁边创建另一张具有相同尺寸的卡片等等(即每次点击都会添加一张卡片,直到连续 4 张,然后从卡片的底部开始直到填满整个页面)。

我不确定如何完成这项任务。所以,我需要你的帮助...

提前致谢

最佳答案

这是我的基本例子

html:

<button class="add">
add
</button>
<div class="main">

</div>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>

j查询:

var card = '<div><p><img src="https://pbs.twimg.com/media/Bd8oIcSCAAAqTaZ.jpg" style="width:60px; height:60px; margin-right:10px">Hello</p></div>';
var hit=0;
$('.add').click(function(e){
e.preventDefault();
hit = hit + 1;
$('.main').prepend(card+' '+hit);
/*$.ajax({url:yourUrl,data:yourData,type:'post',
success:function(data){ // With ajax you can pass hit to your data to get different result
$('.main').prepend(data);
}
});*/
});

JS Fiddle

也许它能帮到你

关于html - 在 Codeigniter 中单击按钮时从数据库添加卡片元素,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47404391/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com