There is a picture, it has an attribute onclick="todo();" So, is it possible with jquery to add certain parameters to the onclick attribute, but this is not the case - $(div).attr(onclick, div.attr(onclick)+todo) and something like this: $(div).attr(onclick, .= todo) that is, as in php, add to the current value?
- oneminimum reproducible example where? some kind of nonsense ... - Qwertiy ♦
|
1 answer
Yes, you can do something like this just by reassigning the onliсk completely for example
var param = 'test'; $(div).attr('onclick','todo("'+param1+'")'); if php something like this, the php part I ask to check for a long time I didn’t write anything on php
<?php $param = 'test' ?> $(div).attr('onclick','todo("<?php echo $param ?>")'); |