You need to provide a more specific selector query. There are several methods to achieve this, but I suggest that using the sibling
property is the most straightforward way if your HTML structure remains constant.
var content = button.previousElementSibling; // Immediately prior to the button
However, choosing the closest
method could be a reliable approach.
var content = button.closest('.read-more-content');
Related Posts:
- How can I reduce the amount of files loaded/included per plugin?
- How can I make content disappear when a user logs in?
- Prevent CSS/JS loading when plugin is not used
- W3 Total Cache: Load CSS asynchronously for better PageSpeed score? [closed]
- Is there an earlier hook than login_head or login_enqueue_scripts?
- Can someone please tell me what is wrong with my plugin?
- How to get DEFER or ASYNC attribute to appear when I add a stylesheet with wp_enqueue_style from a plugin? [duplicate]
- Redirect to another page using contact form 7? [closed]
- how to prevent all css and javascripts files from loading
- How to execute a plugin on a single page only?
- get specific value of a array | PHP
- CSS/JS files in WordPress
- How do I override all stylesheets and scripts without a plugin
- Wp-minify doesn’t seem to minify my JS code
- uncaught TypeError: Cannot read properties of null (reading ‘classList’) custom plugin
- How do I minify a plugins CSS/JS code?
- Custom Plugin scripts from admin working in frontend
- Overriding inline !important CSS with Javscript code snippet with media query
- Speeding up WordPress on a Local Network
- Caching of combined CSS and JS fails because of losing MIME types through combining by PHP
- Speed issues because of CSS & JavaScript
- Best use adding user generated JS/CSS to a theme with a plugin
- How to set up php,javascript and css to allow for our finished product to be displayed within a page?
- Possible jquery / library conflict in plugin usage
- contact 7 plugin stops some pages from working properly
- Element works, but not on wordpress site [duplicate]
- Eliminate Render blocking CSS?
- Sudden ERR_HTTP2_PROTOCOL_ERROR on every JS and CSS files loads
- force enqueue script to be first in order of prominence
- Modifying a JS file with data from plugin settings
- how to include other plugins css files in a shortcode?
- How to call plugin path in JS?
- How can I add a custom header to a custom template in a plugin without using the theme folders
- AJAX Call Via Vanilla JavaScript In WordPress Plugin Development
- wp_enqueue_style in Plugin [duplicate]
- Quote rotator in the sidebar
- How to save Clicks of a download link button while it doesn’t matter if we refresh the page or again login/logout
- ‘Lazy loading’ list of posts with pagination
- Make the css of the widget overwrite theme css
- How to include admin-ajax when loading external javascript
- how would I include a js file with tags into wordpress?
- Custom url structure for custom template
- Google Maps and Yandex Maps doesn’t work correctly
- Override Theme CSS with CSS from a plugin
- do_shortcode() doesn’t work if shortcode contained in variable, works if shortcode passed as string
- How to create popup same as wordpress popup feature
- Gutenberg List Extension Block
- How to add page using HTML, CSS and JS?
- prettyPhoto media loading very slowly in Chrome
- Can we use a webservice with WordPress?
- Pulling data from custom plugin settings using PHP shortcode and Javascript
- Using custom JS plugins with WordPress?
- Override Javascript in a Plugin?
- Globally register styles but enqueue them selectively
- W3 Total cache “empty all caches” and no stylesheets render [closed]
- Add a CSS class based on categroy id to archive pages
- (FES EDD) New vendor submission page is blank
- (Sticky Row) How do i make a row sticky in wpbakery page builder?
- Use of Templates in a Plugin
- add input in custom javascript from WordPress pages/posts
- Redux Framework: Page freezes on typing in Editor
- Template filter for custom taxonomy terms
- Delay JavaScript files from loading
- How do I use add_action on custom widget?
- Overwrite a plugin’s CSS?
- WordPress as template engine
- MediaElement.js works on one site but not the other?
- How to limit image size for the entire website ? But without editing the post (css/plugin?!)
- Opening a JQuery modal window on click of a button with a JQuery plugin
- Is there a way to remove a tooltip of a plugin via custom CSS? [closed]
- Adding a simple Javascript file with a plugin
- Custom CSS not being added by plugin
- How do I show content from a plugin using the template the site is currently working with?
- use EDD Content Restriction for restricting php in template
- Unable to locate inline CSS causing parts of page to be blank
- Two plugins using the same CSS id
- Load CSS before Theme CSS
- login form should redirect to register page for in 1st login next time it should redirected to home page
- the_posts_pagination() not working if I add wp_head() to header.php
- Javascript embedded disappears for editors
- How can I create a secure file download in WordPress?
- WordPress site hamburger menu toggle not working
- Customizer preview URL not updating when settings reset to default
- how to send two forms with one click (script ninjaforms id)
- Link in navigation menu send user to different page if mobile?
- Get plugin to background of page
- How to limit each front-end user to view just his own uploaded files on Amazon S3?
- Need to hide an element depending on date and post category
- Overwrite CSS of Instaemail plugin popup
- Trouble After Update, Removing Plugin
- Plugins to generate CSS Sprites? [closed]
- adding a css file to my plugin
- Display HTML5 jQuery Audio Player On Front Page
- How to display content depending on the Woocommerce Product Category
- Can I merge all my JS and CSS in one file using WP?
- Vanilla javascript in custom gutenberg block not working
- Cannot register a block in my Twig-based theme using Timber for WP
- Can’t change login logo & css – older plugin data blocking?
- How to make a drop-down list so you can press and change display like on this website by using wordpress or CSS
- Prevent part of plugin loading in another menu