Click here to Skip to main content
15,889,034 members
Home / Discussions / Web Development
   

Web Development

 
AnswerRe: How to sync database offline and online application Pin
ZurdoDev28-Mar-16 8:37
professionalZurdoDev28-Mar-16 8:37 
AnswerRe: How to sync database offline and online application Pin
Afzaal Ahmad Zeeshan28-Mar-16 9:50
professionalAfzaal Ahmad Zeeshan28-Mar-16 9:50 
QuestionUnitOfWork And Repository Patterns Not Needed When Using EF Pin
MadDashCoder24-Mar-16 8:34
MadDashCoder24-Mar-16 8:34 
AnswerRe: UnitOfWork And Repository Patterns Not Needed When Using EF Pin
Richard Deeming24-Mar-16 9:13
mveRichard Deeming24-Mar-16 9:13 
QuestionSOMEONE HELP ME FIX THIS. URGENT! Pin
EdzMedallada21-Mar-16 8:33
EdzMedallada21-Mar-16 8:33 
AnswerRe: SOMEONE HELP ME FIX THIS. URGENT! Pin
Serkan Onat21-Mar-16 11:43
professionalSerkan Onat21-Mar-16 11:43 
QuestionDeselecting An Element When Another Element is Selected Pin
MadDashCoder20-Mar-16 21:19
MadDashCoder20-Mar-16 21:19 
AnswerRe: Deselecting An Element When Another Element is Selected Pin
Richard Deeming21-Mar-16 3:22
mveRichard Deeming21-Mar-16 3:22 
First of all, there's no need to use Javascript to change the colour of the row on hover - just use the :hover pseudo-class instead.
CSS
tbody tr:hover { background-color: purple; }

There's no need to remove the class from the row; just add a new class that overrides the colour.
CSS
tr.selected { background-color: gray; }

Add that before the :hover rule, so that the row still changes colour when you hover over it.

Then, you just need to handle removing the selected class from all other rows when you click a non-selected row:
JavaScript
$("table tbody").on("click", "tr", function(){
    var $tr = $(this);
    if ($tr.is(".selected")) {
        $tr.removeClass("selected");
    }
    else {
        $tr.closest("tbody").find("tr").removeClass("selected");
        $tr.addClass("selected");
    }
});

Example: JSFiddle[^]



"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer


GeneralRe: Deselecting An Element When Another Element is Selected Pin
MadDashCoder21-Mar-16 7:49
MadDashCoder21-Mar-16 7:49 
GeneralRe: Deselecting An Element When Another Element is Selected Pin
Richard Deeming21-Mar-16 9:57
mveRichard Deeming21-Mar-16 9:57 
QuestionCan the Prestashop Layered Navigation Block work in Localhost? Pin
Andre HS19-Mar-16 4:20
Andre HS19-Mar-16 4:20 
QuestionDiscount Coupons/Deals site Pin
Riya k Sharma17-Mar-16 7:54
Riya k Sharma17-Mar-16 7:54 
AnswerRe: Discount Coupons/Deals site Pin
Goyllo11-Apr-16 2:31
Goyllo11-Apr-16 2:31 
Questionweb servirce url consume Pin
caradri15-Mar-16 4:09
caradri15-Mar-16 4:09 
GeneralRe: web servirce url consume Pin
Nathan Minier16-Mar-16 2:20
professionalNathan Minier16-Mar-16 2:20 
GeneralRe: web servirce url consume Pin
caradri16-Mar-16 3:08
caradri16-Mar-16 3:08 
AnswerRe: web servirce url consume Pin
caradri16-Mar-16 22:20
caradri16-Mar-16 22:20 
QuestionHow to group 3 form fields into one using bootstrap 3 Pin
Emad Hassan Khan13-Mar-16 1:14
Emad Hassan Khan13-Mar-16 1:14 
AnswerRe: How to group 3 form fields into one using bootstrap 3 Pin
Emad Hassan Khan13-Mar-16 1:37
Emad Hassan Khan13-Mar-16 1:37 
QuestionSending SMS Task Pin
Member 1238760712-Mar-16 7:02
Member 1238760712-Mar-16 7:02 
AnswerRe: Sending SMS Task Pin
Richard MacCutchan13-Mar-16 0:11
mveRichard MacCutchan13-Mar-16 0:11 
QuestionMvc5 or MVC plugin Architecture Pin
Member 1114105611-Mar-16 0:41
Member 1114105611-Mar-16 0:41 
AnswerRe: Mvc5 or MVC plugin Architecture Pin
Nathan Minier11-Mar-16 1:40
professionalNathan Minier11-Mar-16 1:40 
GeneralRe: Mvc5 or MVC plugin Architecture Pin
Member 1114105611-Mar-16 2:23
Member 1114105611-Mar-16 2:23 
GeneralRe: Mvc5 or MVC plugin Architecture Pin
Nathan Minier11-Mar-16 2:45
professionalNathan Minier11-Mar-16 2:45 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.