asked    June     2018-10-22       javascript       120 view        2 Answers

[SOLVED] Alternative solution for :focus on multiple buttons

I'm struggling to find a different solution for :focus when clicked on a button, as Safari doesn't support :focus on buttons.

I have a field of 16 buttons, which should change colours when clicking on it and loose it when different button is clicked.

I have created this fiddle to show the events. toggleClass is not the right solution and would like to avoid :focus.

Current JS code:

$(".tbl-button").on("click", function() {

  2 Answers  

        answered    Warner     2018-10-22      

You can just change your css declaration from .table-btn-color to .tbl-button:active.

but if you want to use jQuery you can do it like this

$(".tbl-button").on("mousedown", function() {
}).on('mouseup', function(){

In order to retain the class on the selected element you can do it like so:

$(".tbl-button").on("mousedown", function() {
  // remove the class form all .tbl-button elements
  // add it to the currently pressed element

        answered    Beryl     2018-10-22      

Can you try replace this: $(".tbl-button:focus").addClass("table-btn-color");

by this $( document.activeElement ).addClass("table-btn-color");

Your Answer

 2018-10-22         Merry

Calculate the area under each peak in a graph in python

I am trying to calculate the area under each peak in a graph that I plotted with a set of x and y co-ordinates, I don't have a function for (x,y), and so I haven't been able to find an appropriate method to do the same.the co-ordinates are { [10 10] [11 1] [12 7] [14 4] [16 8] [17 5]]}And y=0 for all the unmarked x values The area below two points consists of a 'square' part and a triangular part. The trick is to calculate them both separately and add them. Do this for all points, and you get a list of areas under peaks:points = [[10, 10], [11, 1], ...
 python                     3 answers                     55 view
 2018-10-22         Jeff

Time Complexity of while loop

What is the Best case, Worst Case and Average Case scenario of the followingcode segment ? def sumInts(n): Count = 0 while i < n: Count = count + n Return count It doesn't run because there's neither an i nor a count defined anywhere.In other words: Best case: crash, Worst case: crash, Average case: crash. [XXX]
 python                     1 answers                     57 view
 2018-10-22         Jeffrey

Return the rows(Ids) which satisfies and has both the values in IN condition

I have a below table with sample data called Recipes which acts as a junction table between other 2 tables.Query - select recipeId, IngredientId from Recipes where IngredientId in (1,31) order by recipeIdWhen i execute above SQL statement it gives below Output. which is fine.What changes i have to make in the query to get below highlighted Output.Now why 6,7 & 21?As RecipeIds 6, 7 & 21 are the only Ids which has both IngrdientIds [i.e. 1,31] You can use group by clause :select RecipeIds from table twhere IngrdientIds in (1, 31)group by RecipeIds having count(dis...
 sql                     1 answers                     63 view