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
- How to resolve Multisite Speed issues
- taxonomy_template filter do not loads custom taxonomy template properly
- Has anyone used require.js for handling plugin scripts?
- How to override my plugin’s php classes with duplicates that are in my child theme folder
- Passing RichText attributes to function onChange
- Can I share predefined fonts from theme_support with a gutenberg component?
- How do I store information in a dynamic block in WordPress?
- Gutenberg List Extension Block
- Is it possible to use Snap Scrolling? [closed]
- Plugin shortcode won’t work on a custom template file [closed]
- Reuse javascripts from plugins within the theme
- javascript onload calling a function of a plugin
- Image resizing on home page (product category) [closed]
- Override comments.php template with plugin
- How to enqueue a theme style-sheet to my admin settings page?
- Localiztion in javascript
- WP-Cufon adding extra space in my paragraphs in Firefox and Chrome
- How do I write into a file (css)
- How to Include a Loop Template File in a Plugin
- Woocommerce email template customization [closed]
- How to get the HTML until ?
- ‘Customize’ button in admin bar for CSS
- Pass a php string to a javascript variable
- More than one text-domain is being used because of the included templates for plugins
- Why isn’t “background-image: url”working with Bootstrap carousel on WP?
- How to add page using HTML, CSS and JS?
- Problem in loading javascript in footer
- JQuery not working in my plugin [closed]
- How to generate CSS from a shortcode within a plugin
- prettyPhoto media loading very slowly in Chrome
- Add stylesheets and js to template files when shortcode is used
- Custom CSS for plugin form
- How do I modify the position of a plugin?
- Can we use a webservice with WordPress?
- How to load plugin after page is loaded – pagespeed issues
- add mediaelement.js plugins into WordPress video player control bar
- Shortcode button dosent work for all posts. Work for first post only
- Get IDs of Images from Gallery Block in InnerBlocks of a Custom Gutenberg Block
- React JSX in WordPress Plugin Development
- Internationalization autocomplete JS variable
- Pulling data from custom plugin settings using PHP shortcode and Javascript
- Should I fetch the data managed by a plugin by using its APIs or WordPress APIs?
- Using custom JS plugins with WordPress?
- Override Javascript in a Plugin?
- WP Post Template – Templates in own folder
- Register Page Template from Plugin
- plugin style conflicts, how to override? [closed]
- How to disable specific plugin in mobile version?
- How to disable CSS rule in Twentythirteen style.css?
- Theme’s default styles are overriding my plugin’s custom CSS
- Remove ALL css for a specific plugin page
- Best approach to fetch data from wp options to js file or php file
- Globally register styles but enqueue them selectively
- CSS from textarea in options page to frontend what to do
- custom changes removed after plugin update
- W3 Total cache “empty all caches” and no stylesheets render [closed]
- Admin Panel pagination link styles
- How to style the RSS wordpress?
- How Do I Figure Out What File(s) to Edit from Looking at the Source Code [closed]
- Updating the Drag-To-Share eXtended share URLs?
- Scripts at the end of the page
- List Category Posts rewrite necessitates rewrite of customised templates
- wordpress site | All-in-one-cufon IE Issue
- Enqueue WordPress plugin scripts below all other JS
- How to add Internationalization in WordPress using Javascript/React?
- Can I use custom CSS and js plugin to put JavaScript in to validate my forms
- Change upload folder for a CPT
- WPBakery JS composer unused css [closed]
- How to tie dark mode with prefers-color-scheme webkit? [closed]
- How to get the element ID from new menu list that added with add_filter()?
- Override Plugin Script Fucnction in WordPress
- Time consuming callbacks in customizer