samedi 4 mars 2023

how to uncheck checkbox that has specific dynamic value in javascript

i have many checkbox that when user checked one of them , it make an span with ajax with 'tag' attribiute . i want that , when a user click in this spans again , uncheck the checked checkbox, but when i put 't' var in front of value its not working, can anybody help me?

<div id="tags-res">
  <span class="clear-tags" tag="wb=38"></span>
  <span class="clear-tags" tag="attr=33|998"></span>
</div>


<script type="text/javascript">
   $( document ).on( 'click', '.clear-tags', function(){
                    
                var t = $(this).attr('tag') ;

               $(":checkbox[value= t ]").prop("checked","false");
});

</script>



Aucun commentaire:

Enregistrer un commentaire