Awesome q2a theme

How to get the element value?

0 like 0 dislike
22 views
Good afternoon. Let's say the block,and on click I need its value
$('.block1').click(function(){ let a = $(this).data('a'); let b = $(this).data('b'); });
In my understanding it is doing so,and that's the essence of the problem, I need click on another unit No. 2 took values of unit # 1.I can not write let a = $('block1').$(this).data('a'), etc. As in this case, take the value of the first block?There are many values,I can't just write $('block1').data('a')
by | 22 views

2 Answers

0 like 0 dislike
Aleksandr_Markelovif You need a click to take the value from the trail. him block, then all blocks in the array and get the value at this index + 1
Option 2: using jq method .next()
Option 3: add some data-* and determine the desired unit

Ps but it seems to me that you originally came up with some "wonderful"(not Mat) structure and are now trying it has something/to do something.... well or simple - don't need the tonsils through the f**got cut

Start to study design and will, or some nonsense to do... my IMHO
by
0 like 0 dislike
do reference blocks at once

\r\r\r\r\r\r\r


$('.block1').on('click', function(){ var id = $(this).data('block'); $('#'+id).blabla(); });


Ajtishniki, of course, to generate randomly in the output markup

PS
This method is good because it depends on the html structure: block2 can be located anywhere relative to the block1.
by

Related questions

0 like 0 dislike
1 answer
0 like 0 dislike
2 answers
0 like 0 dislike
1 answer
0 like 0 dislike
1 answer
110,608 questions
257,187 answers
0 comments
40,796 users