0
I have the following example that I cannot do.
I have a div:
<div class="dados" data-attribute="2" onclick="bloquearSacado(1,2);">
<p>Teste</p>
</div>
And I have the following code:
status = 3;
codigo = 8;
$('.dados[data-attribute='+ id + ']').attr('onclick',(status+, id));
When I run this code it adds the values 1+8 but I need it to be like this:
onclick="bloquearSacado(3,8);"
What is the right way to concatenate in this situation so that it is equal to the result above?
PS: the ( and , are fundamental.
Thank you very much.
Present the code, it’s easier to show the problem than trying to explain and we’ll still have a [MCVE]
– Leandro Angelo
But I presented the code: it is a div <div class="data" data-attribute="2" onclick="blockSacado(1,2);"> <p>Test</p> </div>
– matheus
That I execute the code $('.data[data-attribute='+ id + ']'). attr('onclick',(status+, id)); with variable status = 2 and id = 9 and it adds the two values in onclick and not CONCATENATE, understood?
– matheus
Where the variable
codigo
get into it?– Sam
I think you put the wrong code. That would be it:
$('.dados[data-attribute='+ id + ']').attr('onclick','bloquearSacado('+status+','+codigo+')');
– Sam
And it doesn’t make much sense for you to have an onClick event and want to bind another one through the selector... present the code
– Leandro Angelo