I have a list of items, which have inputs that are hidden but include all the different values, I How can I get each
& lt; Ul class = "happiness" & gt; & Lt; Li & gt; & Lt; Input type = "hidden" value = "guid-xxxx0" /> Happy & lt; / Li & gt; & Lt; Li & gt; & Lt; Input type = "hidden" value = "guid-xxxx1" /> Sad & lt; / Li & gt; & Lt; Li & gt; & Lt; Input type = "hidden" value = "guid-xxxx2" /> I do not know & lt; / Li & gt; & Lt; / Ul & gt; Is this the right way to do this?
$ ("." Click (function () {var value = $ (this) .Find ("li input"). Val ();});
One click event in the li update element Element has #displayer content, I think there will be more content in practice in . For example:
Array.prototype.forEach.call (Document.querySelectorAll ('li'), function (elem) {elem.addEventListener ('click' , Function () {document.getElementById ('displayer'). TextContent = this.query selector ('input'). Value;});}); , but it does some assumptions such as each li only one input lineage.
No comments:
Post a Comment