gpt4 book ai didi

jquery - 传递 ID 属性

转载 作者:行者123 更新时间:2023-12-01 01:03:36 25 4
gpt4 key购买 nike

我正在使用 .each 函数抓取 div,但在将我获得的 ID 传递到模态框函数时遇到问题。这是代码:

(function() {
$('div.heriyah').each(function() {
$(this).html('<div class="add"><div id="add_button_container"><div id="add_button" class="edit_links">+ ADD NEW CONTENT</div></div></div><div class="clear"></div><div class="placeable"></div></div>');

$('.add').click(function() {
$.fallr('show', {
content : '<iframe width="620" height="600" src="<? echo $URL ?>/manage_content.php?id=<? echo $pageID; ?>&div='+$(this).attr('id')+'"></iframe>',
width : 620 + 5, // 100 = for width padding
height : 600,
closeKey : true,
closeOverlay : true,
buttons : {}
});
});

});

})();

如果我请求模态框中的变量,我会得到未定义

我用这个:

'+$(this).attr('id')+'

获取模态框函数中的 id。

谢谢,鼓手

最佳答案

我不确定 fallr 是什么,但尝试将您的代码更改为:

    (function() {
$('div.heriyah').each(function() {
$(this).html('<div class="add"><div id="add_button_container"><div id="add_button" class="edit_links">+ ADD NEW CONTENT</div></div></div><div class="clear"></div><div class="placeable"></div></div>');

var curID = $(this).attr('id');//get the id before you go into fallr

$('.add').click(function() {
$.fallr('show', {
content : '<iframe width="620" height="600" src="<? echo $URL ?>/manage_content.php?id=<? echo $pageID; ?>&div='+curID +'"></iframe>',
width : 620 + 5, // 100 = for width padding
height : 600,
closeKey : true,
closeOverlay : true,
buttons : {}
});
});

});
})();

关于jquery - 传递 ID 属性,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8185800/

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