I wrote in a corner in a way, and was hoping there was a "easy" way. I am trying to loop through a lot of things on my page, and make a key: value pair here is my structure:
& lt; Div class = "divMapTab" id = "divMaptab34" & gt; & Lt; Div class = "divFieldMap" & gt; & Lt; Select class = "selSrc" id = "selTargetnamex" & gt; & Lt; Options .... & gt; & Lt; / Select & gt; & Lt; / Div & gt; & Lt; / Div & gt; & Lt; Div class = "divMapTab" id = "divMapTab87" & gt; & Lt; Div class = "divFieldMap" & gt; & Lt; Select class = "selSrc" id = "selTargetnamex" & gt; & Lt; Options .... & gt; & Lt; / Select & gt; & Lt; / Div & gt; & Lt; / Div & gt;
This is more complex than that, and there are many select elements within each divFieldMap DIV.
This is my JS function which is preparing my string:
Save function () {var sSaveString = ''; $ ('. DivMapTab') Each (function () {var thisId = this.id; $ ('. SelSrc', "#" + thisId) .each (function () {var thisSubId = this.id; // alert (this sibid); & lt - The problem here is sTargetCol = thisSubId.replace ('selTarget', ''); var sValue = this.val (); sSaveString + = sTargetCol + '¸' + sValue + '·';});}); }
On a warning box and the text "Here is the problem", it is that I am trying to get the value of the "current" input input element, but that element ID is not unique (I thought it would be, but I got spoiled). Is there a good way inside a "every" type of jQuery statement, to use "this" to select "right" that I'm really searching for, even if it does not have a specific ID?
I believe you can use $ (this)
You can create a JQuery reference for the object. Is this what you are doing?
Comments
Post a Comment