Here is my code:
<script type="text/javascript">
function selectedone(str)
{
var classes = "";
$(':checked[class]').each(function(){
classes = $(this).attr("class");
});
var e = document.createElement('strong');
e.setAttribute('id',str);
$("#resultthis").append(e);
row = $("#resultthis").find('#'+str);
$(row).html(classes);
}
</script>
Here for check box:(This one running inside loop)
<input type="checkbox" onclick="resultthis(this.id);" value="<?php echo $a; ?>" id="<?php echo $a; ?>" class="<?php echo $b; ?>"/>
on click on this check box i need to get that class name and create tag inside (#resultthis) div dynamically and set value for that label same as class name. My problem was every time i click check box its setting multiple time vaue in side label. How to resolve this?
are you trying to achive this ? if yes then you should use .html()
instead of .append()
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.