gpt4 book ai didi

php - onclick 将元素类传递给 javascript

转载 作者:搜寻专家 更新时间:2023-10-31 20:55:17 25 4
gpt4 key购买 nike

我写了这样的代码

<?php
$extCount = 0;
foreach($this->externalReferal as $externalReferal)
{
$extCount++;
?>

<div class='fieldtestPct' >
<div class='fieldItemLabel'>
<label for=''><?php echo $externalReferal->getConsultantname(); ?> ( <?php echo $externalReferal->getSpeciality(); ?> )</label>
</div>
<div class='fieldItemValue'>
<input type='checkbox' class='ext_ref_list<?php echo $extCount; ?>' name='ext_ref_cons[]' value="Consultant<?php echo $extCount ?>" >
</div>
</div>

<div class='fieldtestPct'>
<div class='fieldItemLabel'>
<label for=''>Current Visit</label>
</div>
<div class='fieldItemValue'>
<input type='checkbox' class='current_visit<?php echo $extCount; ?>' name='current_visit[]' value="" onClick ='currentVisit(this.class)'>
</div>
</div>
<div class='fieldtestPct'>
<div class='fieldItemLabel'>
<label for=''>Full Data</label>
</div>
<div class='fieldItemValue'>
<input type='checkbox' class='full_data<?php echo $extCount; ?>' name='full_data[]' value="" onClick='fullData(this)'>
</div>
</div>

<div class='clear'></div>
<?php
}
?>

在这里,我需要在单击复选框时执行动态操作。我如何将选定的元素类/数据传递给 javascipt。

最佳答案

使用 this.className 而不是 this.class

The name className is used for this property instead of class because of conflicts with the "class" keyword in many languages which are used to manipulate the DOM.

https://developer.mozilla.org/en/DOM/element.classname

关于php - onclick 将元素类传递给 javascript,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3369948/

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