JavaScript How can you add a class to a tag with a custom attribute in JQuery? classu003d custom-file-input,classu003d custom-select,classu003d custom-control-

How can you add a class to a tag with a custom attribute? Most people use ID, but in my case I need to use a custom attribute.

CSS:

.correct {
    background-color: lightGREEN;
}

JQuery:

$(".save").on("click", function(){
    $("input[custom='50']").addClass("correct");
}

HTML:

<button type='button' class='save' value='Save' custom='50' >Save</button>

bootply:

http://www.bootply.com/XgCASbBRZR

Answer:1

You're missing a parenthesis in your jquery, and are adding the class correct to an input, so I added the input to your html.

$(".save").on("click", function(){
    $("input[custom='50']").addClass("correct");
});
.correct {
    background-color: lightGREEN;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<button type='button' class='save' value='Save' custom='50' >Save</button>
<input custom="50">
Answer:2

I'm trying to have same size images with flexbox. I give a display: flex; to my slick-track container and then flex: 1 0 auto to my img. I thought that with a flex-grow of 1 my image will increase if ...

I'm trying to have same size images with flexbox. I give a display: flex; to my slick-track container and then flex: 1 0 auto to my img. I thought that with a flex-grow of 1 my image will increase if ...

  1. same height images css
  2. same height images bootstrap
  3. same height images
  4. equal height images css
  5. equal height images bootstrap 4
  6. equal height images flexbox
  7. equal height images
  8. same height couples images
  9. flex same height images
  10. same height and width images
  11. slick slider same height images
  12. owl carousel same height images
  13. images same height html

On this page here. It's possible to see that the Facebook login button is initially disabled. (Using [disabled]="myProperty") Once an API request /facebooklogin/isnewuser returns, it is enabled. ...

On this page here. It's possible to see that the Facebook login button is initially disabled. (Using [disabled]="myProperty") Once an API request /facebooklogin/isnewuser returns, it is enabled. ...

I am trying to create a game for fun in Captivate. The game will mimic a wheel of fortune or spin the wheel format. I am trying to put a different spin on it, and not have any repeating numbers. ...

I am trying to create a game for fun in Captivate. The game will mimic a wheel of fortune or spin the wheel format. I am trying to put a different spin on it, and not have any repeating numbers. ...

  1. javascript captivate 2017
  2. captivate javascript commands
  3. captivate javascript examples
  4. captivate javascript change state
  5. captivate javascript api
  6. captivate javascript jump to slide
  7. captivate javascript variables
  8. captivate javascript functions
  9. captivate javascript go to next slide
  10. captivate javascript show hide
  11. captivate javascript interface
  12. captivate javascript alert
  13. captivate javascript advanced actions
  14. captivate javascript library
  15. captivate javascript go to slide
  16. captivate javascript play video
  17. captivate javascript next slide
  18. captivate javascript reset quiz
  19. captivate javascript pause
  20. captivate javascript close window

I'm trying to create a number field (.item_adults) that multiply it self and print the value into a class="item_price". To do that I create some of this: <div class="bookSection"> <input ...

I'm trying to create a number field (.item_adults) that multiply it self and print the value into a class="item_price". To do that I create some of this: <div class="bookSection"> <input ...