Skip to content
Advertisement

Capture text inside a using JavaScript

I need to create a shopping cart. When I click the button “Add to Cart”, the item in the “p” should appear in the screen.

PHP

JavaScript

JAVASCRIPT

JavaScript

Advertisement

Answer

The p tag is not a object with value attribute, you should use:

JavaScript

but first of all you must change your PHP code, you generate multiple

tags with same ID, so there is no unique ID you can handle. So make them unique and try with:

PHP

JavaScript

JAVASCRIPT

JavaScript
User contributions licensed under: CC BY-SA
2 People found this is helpful
Advertisement