gpt4 book ai didi

javascript - 显示类名

转载 作者:行者123 更新时间:2023-11-30 18:10:19 26 4
gpt4 key购买 nike

大家好,我这里有一个 Javascript 代码,它使用通过 ASP 页面从数据库中获取的按钮属性创建 HTML 按钮 onload。现在我想显示这些属性,我可以显示 id、类型和值,但类显示为未定义。我转到浏览器上的页面并检查了元素并显示了类,但没有显示在警告框中。请帮助...

function createButtons(tbID, tbClass, tbType, tbValue, onClick) {
return '\n<input'
+ (tbID ? ' id=\'' + tbID + '\'' : '')
+ (tbClass ? ' class=\'' + tbClass + '\'' : '')
+ (tbType ? ' type=\'' + tbType + '\'' : '')
+ (tbValue ? ' value=\'' + tbValue + '\'' : '')
+ (onClick ? ' onclick=\''+ onClick + '\'':'')
+ '>';

}


function DisplayButtons(cableData) {

var newContent = '';

$.each(cableData, function (i, item) {

newContent += createButtons(
item.CommonCable,
"unclickedButton",
"submit",
item.CommonCable,
'alert(this.id + " " + this.class + " "+"clicked")'
);

});


$('#Categories').html(newContent);

}

最佳答案

this.class 更改为 this.className..

关于javascript - 显示类名,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14751749/

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