Take the 2-minute tour ×
Stack Overflow is a question and answer site for professional and enthusiast programmers. It's 100% free, no registration required.

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?

share|improve this question
    
please explain ur problem in simple words.. and what you want to achive ? you want it to set only once ? –  Saurabh Feb 7 at 5:58

1 Answer 1

are you trying to achive this ? if yes then you should use .html() instead of .append()

Fiddle demo

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.