Bonjour.
je possède une image avec dessus des zones réactives sur lesquelles on peux cliquer afin de faire une selection de la zone cliquée.
Cependant on peux faire une selection multiple.
J'aimerais bloquer cela et permettre une unique sélection.
Comment faire cela?
ou alors c'est ici
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25 $(document).ready(function() { // Disable various aspects of passenger details table $('#passenger_details input, #passenger_details select').attr('disabled', 'disabled'); // Add class="selected" to tab + tbody $('#tabs a:first, #passenger_details tbody:first').addClass('selected'); // Get the value of the tab link, and display tbody $('#tabs a').click(function() { // Switch class="selected" for tabs $('#tabs a').removeClass('selected'); $(this).addClass('selected'); // Asign value of the link target var thisTarget = $(this).attr('href'); // Show target tbody and hide others $('#passenger_details tbody').removeClass('selected'); $(thisTarget).addClass('selected'); this.blur(); return false; } );Merci par avance.
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52 // Add click listener to seats $('#airplane a').click(function() { // Asign value of the link target var thisTarget = $(this).attr('href'); // Show target tbody and hide others $('#passenger_details tbody').removeClass('selected'); $(thisTarget).addClass('selected'); // Swap out class="selected" for tab $('#tabs a').removeClass('selected'); $('#tabs a[@href='+thisTarget+']').addClass('selected'); // Assign the value of the parent <li class="*"> var thisSeat = $(this).parent('li').attr('class'); // Compare parent <li class="*"> against // <tr> in <table id="passenger_details"> var thisRow = $('#passenger_details tr'); for (var i = 0, j = thisRow.length; i < j; i++) { if (thisSeat == thisRow[i].className) { // Add class="selected" to row $(thisRow[i]).addClass('selected'); // Enable inputs and selects so that they can be used $(thisRow[i]).children('td').children('input, select').removeAttr('disabled'); } else if (thisSeat + ' selected' == thisRow[i].className) { // Remove class="selected" from row $(thisRow[i]).removeClass('selected'); // Disable inputs and selects that aren't being used $(thisRow[i]).children('td').children('input').attr('disabled', 'disabled').val(''); $(thisRow[i]).children('td').children('select').each(function() { this.disabled = true; this.selectedIndex = 0; } ); } } // Toggle selected class on/off $(this).toggleClass('selected'); this.blur(); return false; } );
Partager