How to insert a value into javascript code if it is already taken? In short, there is a variable

id=107; 

And then the code goes like this (sampling of all paragraphs by id ):

 $('p[id=id]').text('New value'); 

I tried changing the id to another variable, but nothing happened. So how is it right to embed values ​​in JavaScript ?

    1 answer 1

     $('p[id='+id+']').text('New value'); 

    Not?

    And further:

    Digital ID set is not accepted. For a long time to explain why, just variables of this kind usually begin with a letter.

    And your code is not jquery) is

     $('#'+id).text('New value'); 
    • Thanks) - alex_90