I have a custom WooCommerce product type. If you switched between the standard WooCommerce type the input are cleared but this does not work for custom types.
So I created a jQuery for this
$('#product-type').on('change', function() {
//do something
});
But this is not the solution because the functions in this code are also running if the page is refreshed.
What can I do to let this work only if the product type is changing
WooCommerce set the product type with JavaScript and is not set wit PHP. They use the change function if the page is loading and set the right product type on screen.
If you need a function on a specific product type you can do something like this
$('#product-type').on('change', function() {
if($('#product-type').val() == '//your type'){
//do something
}
});
Put your code inside the ready event. The code inside this function fires only when the DOM is completely loaded.
$(document).ready(function(){
$('#product-type').on('change', function() {
//do something
});
});
Why does IntelliJ has inspections for generic usage disabled by default?
I want to validate user input so he only provides numbers from a certain range with 0,5 stepsBut I want my website to do it every time user swaps to another input form, not after he sends the data to my view
enter image description here
My database is running fine because I tested it using Eclipse with simple Java code that just connects and reports back success or failI connect fine