Home > database >  How can I change my code so that I don't have to use a script for all single record?
How can I change my code so that I don't have to use a script for all single record?

Time:01-05

So here it is by browsing my records each time I have to create a code with the ID how to make just one function for all the records?

$tbody .= '<script> 
$(document).ready(function(){
$("#img'.$idImage .'").click(function () { $("#img'.$idImage.'").toggleClass("minresize") } );  
});
</script>';

$tbody .= '<td><img id="img'.$idImage .'"  src="'.ASSETDIRECTORY.'uploads/'.$value.'" alt="'.$value.'" title="'.$value.'"></td>';

CodePudding user response:

Actually this is working perfectly. Thank you Luc Laverdure your comments put me on the right track.

<img  src="'.ASSETDIRECTORY.'uploads/'.$value.'" alt="'.$value.'" title="'.$value.'" onclick="$(this).toggleClass(\'maxresize\');" >

CodePudding user response:

something like this?

<img src="<?php echo ASSETDIRECTORY.'uploads/'.$value; ?>" alt="<?php echo $value; ?>" title="<?php echo $value; ?>" onclick="$(this).toggleClass('minresize');"  />
  • Related