So your script is doing exactly what you have told it to do.
Here you are passing the element to the function, but you never use it, instead you just query all elements with a class and add another class.
function moreinfoModal(field) {
console.log(field.id);
$('.moreinfo-modal').toggleClass('open');
}
What you should do is only add the class to the element the buttin is targeting:
function moreinfoModal(field) {
// Get the button target.
var target = field.getAttribute('data-target')
// Add class to target.
$(target).addClass('open');
}
And when you need to close the model window. You can just look for only models that are open. As you aren’t passing an element in to get the id from.
function closeMoreInfoModal() {
// Close all windows because you we dont have the open elements id.
$('.moreinfo-modal.open').removeClass('open');
}
Related Posts:
- Adding custom input for data attribute in insert media modal
- overwrite wordpress gallery with custom gallery shortcode
- JQuery modal not loading video on popup, only displaying it after multiple reopenings
- custom post type not showed with bootstrap 4 modal and template part
- PHP XMLRPC for WordPress: Adding meta tags and description
- Real time Duplicate title check
- Blank on static home page?
- probleme adding Txt and Links in preg_match()
- Correct use of curly braces vs alternative synax
- Adjust the results quantity for Search Results page pagination
- Audio tags around Mp3 URL in content
- the_author_meta not working
- Missing Author Information
- Configuring WP-CLI on Windows 10
- Assign a picture URL to a page via PHP
- Check if Product is in a Specific Category in Functions.php
- Display user role Name – not slug
- Adding ads code between comments
- How to create and work with custom data / tables (i.e., for arbitrary data)?
- How to add custom post meta to default blog post?
- Limiting woocommerce line_total decimal length
- Shortcode content filter?
- Fetch posts from category in custom page template
- only show container with next/prev links if they exist?
- JS file work only in index page
- If no products are on sale – hide ID or class
- Update grandchild repeater field with value per row
- Paypal form integration with wordpress registration form without plugin [closed]
- How to get the value of input hidden html from text editor to custom page template?
- Uploading files using the Settings API
- fatal error call to undefined function get_header in index.php on line 1
- Plugins not working on AJAX requests
- Fetching instagram api not working on wordpress
- add_theme_page to add_menu_page theme options convert
- JQuery calling a Custom PHP function (Works in Dev but not in WordPress)
- Jquery function working in Dev Console but not otherwise [duplicate]
- height should be set to auto to avoid pixelation in the post thumbnail function
- Get posts from multiple post type
- How to convert select to HTML with PHP tags inside of it [closed]
- get the correct url for an folder in wp-includes wordpress
- Can i put my shortcode inside a variable in php files?
- Can’t access site after making changes to the functions.php [closed]
- Replace Woocommerce “add to cart” to be “Download” button [closed]
- JS value to PHP variable to change div background color with PHP If else statement
- Store post content in a php variable and output them using for loop
- Running rmdir function on post save
- Simple AJAX notification when the new post is added to the database
- Upload multiple files in randomly generated folder using wp_upload_bits
- Loading two post layouts for the same post with different url
- How to display a custom product field value of a specific category on a Woo Commerce checkout page?
- Parse error: syntax error, unexpected ‘}’ [closed]
- Personalize checkout text
- Adding an interior ‘hero’ area with some added php title customization
- Nginx WordPress and another Web app URL structure
- Creating customized php files in theme folder
- Using an “IF” statement based on the existence of custom field
- WordPress time queries
- How to put search bar & logo in the “primary navigation” storefront theme?
- Providin exception to WordPress wp_nav_menu Custom CSS Classes
- Send an e-mail on address with the link with disliked post
- List sub categories and corresponding posts of a parent category
- Woocommerce My acount page
- Time Stamp In A WordPress Post Title That Does Not Keep Refreshing
- Display featured image of post type category
- IF statement not working – Any suggestions?
- Child theme overirde template-tags in a theme built on underscores in inc/template-tags
- Pages from admin dasboard missing after site migration
- using filter and hook inside class
- $.ajax results in 403 forbidden
- Menu not updating for logged in users after redirect
- Change upload URL by mime type
- in the post admin, is it possible to make the post title input disabled using php?
- Editable Student file associated with basic User ID
- html to posts, jpg to featured image, zip file contains jpg and html
- views How to load javascript on custom page template?
- Two theme locations for two menus, but only one is showing up
- How to set the plugin load order when updating the active_plugins option?
- Display Year and Month from custom field + Age Calculator
- Contact form field in wordpress menu
- Shortcodes (with a space) added to php Sample
- No Authors for custom post type
- How Can I Center the Logo in the Navigation Menu? [closed]
- Sort posts by title, sort array by largest number [duplicate]
- Get author meta of all writers
- Creating a function that sanitizes the custom metabox excerpt
- Nav Menu Display
- WordPress & PHP sessions
- How to add pagination for wordpress home page
- which php or css file has generated an inline style in WordPress that overwrites my css
- Change body_class() PAGE to HOME
- How to create shortcode of this PHP code
- understanding wp_next_scheduled
- WordPress 6.1.1 UTF8 Slug Limit Increase
- WordPress directories not writable after PHP version upgrade
- How do I unset category from a product in wordpress by code
- php 8 compability admin interface
- How can I make below code to show grouping by country ranks in same div, example if in second loop rank 2nd must be show in same 2nd class div
- add_rewrite_rule image from /images/site2/favicon.ico to /favico.ico
- Load style and script for custom post type metabox
- Permissions error when I use my plugin to delete comments in the front-end