I need help of Javascript / jQuery experts to solve the next problem:
---- 1. this Javascript alerts the id of a selected option in a select html tag:
The jQuery $("#...")
syntax will return the first matched element by exact id. If you are cloning elements but not differentiating them by their id, this code will not work as you expect it to.
You can compare the differences between the following two expressions:
alert($("#id_productos_list").size());
...and
alert($("[id='#id_productos_list']").size());
The first expression will return either zero or one depending on the presence of an element with id "id_productos_list" in your page. The first element in declared order wins.
The second expression will return zero or one or more depending on the the set of all elements with id "id_productos_list" in your page.
Also important to note is that it doesn't appear that the event handlers are copied over as part of the clone()
operation. You may need to reassign these handlers to the new elements.
var newElement = $(selector).clone(true);