jessepollak / card

:credit_card: make your credit card form better in one line of code
MIT License
11.66k stars 1.48k forks source link

how to flip card from js code #556

Closed darkworks closed 2 years ago

darkworks commented 2 years ago

Am wondering how can i flip card manually like calling from js code , normally when u click on cvc field and input the card number its flipped . so am wondering how can we flip it through js code , any js method function which need to be called ? also other features like export image , svg etc will be good if added.

thanks

melloware commented 2 years ago

If your CVC input field is id="cvc" for example you can flip the card like this...

document.querySelector('#cvc').dispatchEvent(new Event('focus'));
darkworks commented 2 years ago

thanks :)

darkworks commented 2 years ago

@melloware one more question , can u tell how to change color of the card via js like by setting custom hex color ? i tried but no success jQuery(".jp-card-back:before").attr('style','background-color:'+color); thanks

melloware commented 2 years ago

That I am not sure of with jquery as the cards are all rendered with some complex CSS so you might have to dig into it.

darkworks commented 2 years ago

That I am not sure of with jquery as the cards are all rendered with some complex CSS so you might have to dig into it.

ya i checked sad thing is that annoying :before is used which is very hard to modify on runtime is its not part of dom :(

.jp-card.jp-card-visa.jp-card-identified .jp-card-front:before, .jp-card.jp-card-visa.jp-card-identified .jp-card-back:before {
    background-color: #191278;
}

is it possible to change this color to normal css class instead of :before or ;after so that it give us devs control to set credit color as we like

thanks

melloware commented 2 years ago

I didn't design this library but changing all the cards now seem like a task that is not going to be done unless you make the changes and submit a PR

darkworks commented 2 years ago

I didn't design this library but changing all the cards now seem like a task that is not going to be done unless you make the changes and submit a PR

ok right i will play with it to see how it goes