开发者

onclick pass class of element to javascript

开发者 https://www.devze.com 2023-01-09 18:37 出处:网络
i wrote a code like this <?php $extCount = 0; foreach($this->externalReferal as $externalReferal) {

i wrote a code like this

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

    <div class='fieldtestPct' >
      <div class='fieldItemLabel'>
                <label for=''><?php echo $externalReferal-&g开发者_如何学Got;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
}
?>

Here i need to do dynamic action on click of checkboxes. how do i pass the selected element class/data to javascipt .


Use this.className instead of 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

0

精彩评论

暂无评论...
验证码 换一张
取 消