JavaScript Changing Bootstrap Glyphicon on click change bootstrap glyphicon color,change bootstrap glyphicon size,bootstrap change

I'm wanting to swap the second class of Bootstraps 'glyphicon' span, but instead of toggling the class, It's adding it behind, thus not changing the class at all.

I'm new(ish) to jQuery / Javascript and I just can't get my head around this.

Heres the

<nav class="navbar navbar-top" style="position:fixed; width:100%;">
<a class="navbar-brand" target='_blank' href="#">Project name</a>
<a class="navbar-brand" target='_blank' href="#" style="float:right;">
    <span class="glyphicon glyphicon-tasks" id="whiter"></span>
</a>

And the script is below:

$('.glyphicon').click(function(){
$(this).toggleClass('glyphicon-chevron-up');

I get all the classes instead of just glyphicon-chevron-up, Im getting:

<span class="glyphicon glyphicon-tasks glyphicon-chevron-up"></span>

Removing the glyphicon-tasks class on Element inspect displays the Chevron, so some how it is being blocked and the tasks glyph isnt being swapped.

Answer:1

I think you want to swap glyphicon-tasks and glyphicon-chevron-up. You need to toggle both class like following.

$(this).toggleClass('glyphicon-tasks glyphicon-chevron-up');
Answer:2

This is because your function is set to class, which mean all elements with the given class.

To focus a specific element, provide, for example, an unique ID. Here, you already got one.

$('#whiter').click(function() {
    $(this).toggleClass('glyphicon-chevron-up');
});
Answer:3

I guess this can help

$('.glyphicon').click(function(){
$(this).removeClass('glyphicon-chevron-up').addClass('glyphicon-chevron-up');
}
Answer:4

I'm almost done with my project, but the specifications for my login is not yet 100% done. Remember me function is not yet working. HTML <input type="text" id="signinId" class="email-input" ...

I'm almost done with my project, but the specifications for my login is not yet 100% done. Remember me function is not yet working. HTML <input type="text" id="signinId" class="email-input" ...

$("body").on('click', 'button', function(e) { var selection = window.getSelection().toString(); alert(selection); }); <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery....

$("body").on('click', 'button', function(e) { var selection = window.getSelection().toString(); alert(selection); }); <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery....

Consider the following URLs: <http://www.google.com> <http://www.google.com|www.google.com> <http://google.com|google.com> I'm trying to figure a RegEx that would capture the URL ...

Consider the following URLs: <http://www.google.com> <http://www.google.com|www.google.com> <http://google.com|google.com> I'm trying to figure a RegEx that would capture the URL ...

  1. regex capture between two strings
  2. regex capture between quotes
  3. regex capture between brackets
  4. regex capture between two characters
  5. regex capture between parentheses
  6. regex capture between html tags
  7. regex capture between commas
  8. regex capture between two patterns
  9. regex capture between
  10. regex capture between tags
  11. regex capture between spaces
  12. regex capture between strings
  13. regex capture between square brackets
  14. regex capture from to
  15. regex capture from string
  16. regex capture everything between
  17. regex capture group between two characters
  18. regex capture everything between quotes
  19. regex capture text between two strings
  20. regex capture everything between two words

I'm working on a voxel engine that uses WebGL directly. The textures look great within a voxel-engine game (which uses three.js), but look horrible in my engine. Here's an example with a simple grass ...

I'm working on a voxel engine that uses WebGL directly. The textures look great within a voxel-engine game (which uses three.js), but look horrible in my engine. Here's an example with a simple grass ...