Revert to previous dropdown options after change

You’re setting the HTML of the second drop down to essentially blank with: $(‘select[name=”second_dropwdown”]’).html(“<option>Sorry, no options</option>”); So when you enable it again, that’s the only option. Instead, you might try including that as an actual option within your select and then selecting it when disabling the second drop down. You could either include it in … Read more

Change zurb foundation top bar style on.scroll in wordpress theme using jquery and css

You need to fully reference jQuery throughout your code. It should be… jQuery(window).on(“scroll”, function() { if(jQuery(window).scrollTop() > 50) { jQuery(“.top-bar”).addClass(“active”); } else { jQuery(“.top-bar”).removeClass(“active”); } }); When in no-conflict mode you need to always reference jQuery in full and not use the $. No conflict mode exists to prevent conflicts when jQuery is used with … Read more

How to refresh a page from jquery [closed]

jQuery(document).ready(function ($j) { $j(‘#wp_button’).on(‘click’, function() { var data = { action: ‘response’, myid: ajax_var.mypostid, ajaxvar: variable, }; $.post(ajax_var.ajaxurl, data, function(response) { alert(response); location.reload(); }); return false; }); });

Conditional Tags – Multiple Categories

As Mayeenul said in the comment you can use: if($category[0]->name == ‘News’ || $category[0]->name == ‘home-news’) { … And to follow up on your comment about the title flashing in, this is because the jQuery is run after the browser has already rendered the content so there’s a brief moment when it’s shown before jQuery … Read more

Can’t execute jQuery before my script

Try two things – 1. Link your js using wp_enqueue_script action as under : add_action( ‘wp_enqueue_scripts’, ‘theme_name_scripts’ ); function theme_name_scripts() { wp_enqueue_script( ‘script-name’, get_template_directory_uri() . ‘/js/example.js’, array(‘jquery’), ”, true); } Third parameter in wp_enqueue_script() function will make sure jquery is loaded before your current js file. Inside your js file, replace $ with jQuery as … Read more

Duplicate “default” form with jQuery

I don’t know your html code, but here is how it will work. The idea is that you keep the original hidden elsewhere. HTML <button class=”add-form”>add form</button> <form id=”main-form”> <div class=”form-item row”> <input type=”text” name=”abc”> </div> </form> <div class=”stay-hidden original-form-item”> <input type=”text” name=”abc”> </div> CSS .stay-hidden { display:none; } JS // Add form jQuery(‘.add-form’).click(function() { … Read more

Bootstrap modal with jQuery post [closed]

If process.php is not found, your reference in the file is not correct. Make sure you reference to the correct path, for istance – if the file is in the rootdirectory of your site, add a slash in front of your code: url: “process.php”, will be: url: “/process.php”, If it is in the ‘ajax’ directory: … Read more

Add loggedout class on body using a function or JS

Presumably your theme is using the body_class function to output classes. You can add a filter to remove or add your own classes. function wpd_logged_out_body_class( $classes ) { if( ! is_user_logged_in() ){ $classes[] = ‘loggedout’; } return $classes; } add_filter( ‘body_class’, ‘wpd_logged_out_body_class’ );