choose javascript variable based on element id from jquery -
I think this is a simple question, but I am still relatively new to javascript and jquery.
I am developing a site for a touch interface which uses unordered lists and jquery .click functions to capture input data. I have one block with 3 divisas: SS is a section to input time, each has a list of points for the time. I have to get input for each column and set it as a variable. I originally created the input to change the form input, because I did not understand javascript very much, using Div id was easy to change to 3 hidden inputs, but how can I understand this now with javascript variables? P>
This is my original jquery code ...
$ ("div # timings> div> ul & gt; li) click (function () {Var id = $ (this) .parents (". Time"). Attr ("name"); var number = $ (this) .HTML (); $ ("input #" + id) .val (number) ;});
the last one I set one of the hidden inputs out of 3 in which the click was done in the person. I need to do this so that I can move different variable input, but I can manipulate those variables, though I want to.
There is a small snippet of HTML, to know how jquery captures it.
M: < / Pre> full time html Yes:
Thanks everyone!
I am using SO to answer many questions, but I did not get anything for it, so I thought that I would join, because I am sure that there will be more questions on the way.
So I have tried to add the following, and I still can not get it to do the right thing.
window.myValues [id] = number; Event [i] .min = myValues ["minute"]; Event [i] .sec = myValues ["second"]; Event [i] .sin = myValues ["single"]; Event [I] Time = string (event [i]. Minus) + string (event [i] .sec) + string (event [i] .seen);
I tried it with both and without quotation marks I have not used the window. * Anything, so I'm not sure how to handle it.
The first thing to mention here, should not be unnecessary. In your example
$ ('# time'). ('Li'). Click ()
should be enough if I understand you well, then you want to store some data. You may want to use the jQuery method. Example:
$ ('# time'). ('Li'). Click (function () {var $ this = $ (this); var name = $ this.closest ('time'). Attr ('name'); $ .data (document.body, name, $ this Html ());});
This will store the HTML of the clicked link in a global object,
warning ($ data (document.body, 'min' ));
Comments
Post a Comment