MyBB Community Forums

Full Version: Something i have written is not wrking.
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
<script type="text/javascript">
	$(".label-{$multitid}").on("click", function(){ 
  $(".label-{$multitid}").toggleClass('active');
})
</script>


Why this isn't working ?
if you use {$multitid} to detect click source you dont need to do this you can add a static class to all like this class="label"
and your jquery code be like this

$(".label").on("click", function(){ 
  $(this).toggleClass('active');
});
also if your element add to page dynamiclly you can add event handler like this

	$("body").on("click",".label" function(){ 
  $(this).toggleClass('active');
});
No i have written that on purpose to detect the id numbers
(2022-09-27, 09:41 PM)PARADOXP Wrote: [ -> ]No i have written that on purpose to detect the id numbers

you can use data attribute like this

<div class="label"  data-tid="{$tid}"></div>
then on click you can get tid like this
$(".label").on("click", function(){ 

  var tid = $(this).data('tid');

});
Thanks for your help .