Search
 
SCRIPT & CODE EXAMPLE
 

HTML

how to keep :active css style after click a button

<!-- CSS Solution -->
<style>
  .active:active {
    color: red;
  }
  .focus:focus {
    color: red;
  }
  :target {
    color: red;
  }
</style>

<button class='active'>Active</button>
<button class='focus'>Focus</button>
<a href='#target1' id='target1' class='target'>Target 1</a>
<a href='#target2' id='target2' class='target'>Target 2</a>
<a href='#target3' id='target3' class='target'>Target 3</a>

<!-- JQuery Solution -->
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<script>
  $('button').on('click', function(){
    $('button').removeClass('selected');
    $(this).addClass('selected');
  });
</script>

<style>
  button.selected{
    color:red;
  }
</style>

<button>Item</button><button>Item</button><button>Item</button>
Comment

PREVIOUS NEXT
Code Example
Html :: navbar horizontal in html 
Html :: html how to play gifs 
Html :: The size of BLOB/TEXT data inserted in one transaction is greater than 10% of redo log size. Increase the redo log size using innodb_log_file_size. 
Html :: p tag html 
Html :: input type on click submit buttom show 
Html :: make checkbox required 
Html :: email confirmation html template 
Html :: html data-target modal 
Html :: how to add an input next to each other 
Html :: bootrsrap 
Html :: input type tel 
Html :: meta description tag in html 
Html :: html new line without <br 
Html :: skip line html 
Html :: how to add bar notation in html 
Html :: on phone option html 
Html :: how to remove box from form in html 
Html :: pug meta viewport 
Html :: how to add subtitle file in a movie in html 
Html :: lazy load 
Html :: viñetas html 
Html :: color selector html 
Html :: jumbotron code without using jumbotron 
Html :: how to set timeout for a div tag in html 
Html :: html newline 
Html :: class disabled 
Html :: react createContext usage 
Html :: how to do a line break in html 
Html :: th tag in html 
Html :: ins html 
ADD CONTENT
Topic
Content
Source link
Name
6+5 =