Having difficulties with JQuery clone()
You can see what I am trying to do in this jsfiddle: http://jsfiddle.net/pV6x5/16/
The original set of three dropdowns are using javascript to generat开发者_如何学Pythone what options are available in the second and third dropdowns based on the selected value of the first.
When this is cloned and you select an option in the first drop-down of the clone, it is the 2nd and third dropdowns of the original that change and I don't know how to fix this :S
Any help would be much appreciated.
Thanks,
Martin
UPDATE After some reading, I have changed the id's to just use classes in order to try and avoid any clashes: http://jsfiddle.net/QbfXq/1/
Unfortunately it seems to still behave exactly the same as before.
Hi there I did some modifications in your code Here. I only did modify the first 4 or 5 options, you'll have to modify the remaining code yourself.
The major problem is that when you clone, the class and name remain the same for each element.
Then you only initialized values and operand object one time in ($(document).ready
), so that's why you kept modifying the same element.
In my code, I did look for the next element of the clicked arg.
But I think you should organize a little bit more your code, using <div>
for examples would allow you to be more precise using the request.
Instead of using next
you could use a search in div children for example.
Well I hope you see the way it should work.
精彩评论