-2

I am using Javascript in my php application.I am stuck in one line\this is the line

'<td><input type="button" onClick="$(this).closest('tr').remove();" value="x" class="btn btn-primary"></td>'

I want to concatenate that ('tr') that is present with closest.

There is issue with double quotes and single quote.

T.J. Crowder
  • 1,031,962
  • 187
  • 1,923
  • 1,875
Hemant Patil
  • 331
  • 2
  • 18

1 Answers1

0

You are using single quote within a single quoted string. So you have to escape the quotes with \

echo '<td><input type="button" onClick="$(this).closest(\'tr\').remove();" value="x" class="btn btn-primary"></td>';

for javascript also it is the same

var x = '<td><input type="button" onClick="$(this).closest(\'tr\').remove();" value="x" class="btn btn-primary"></td>';
Tintu C Raju
  • 2,700
  • 2
  • 21
  • 25