Implementing modifications to all HTML elements simultaneously

In my HTML document, there are around 80 small boxes arranged in a grid layout. Each box contains unique text but follows the same structure with three values: name, email, and mobile number.

I need to switch the positions of the email and mobile number values in each box. Doing this manually is time-consuming. Is there an automated way or tool that can make this process quicker by allowing me to change one box and automatically apply the changes to all others?

Here is the code for the boxes:

<div class="row gutters-40">
      <div class="col-12 col-md-4 col-sm-4">
        <div class="thumbnail">
          <h4 class="service__title">Private limited Registration</h4>
          <h2 style="font-weight: bold; color: purple; font-family: sans-serif;"><i class="fa fa-rupee"></i> 7500 Rs</h2>
           <h5 class="doctype">Documents Required</h5>
           <div class="docs">
             <ul>
               <li>Aadhar card & Pancard of Directors</li>
               <li>Photo of Directors</li>
               <li>Address Proof of Directors</li>
               <li>Address Proof of Company address</li>
              <li>Qualification & occupation of directors</li>
              <li>Bank statement of Directors</li>
             </ul>
           </div><!--docs ends here-->
           <div class="price_time">
            <p class="service__paragraph" align="left" id="price"><i class="fa fa-info-circle"></i> Know More</p> 
           </div>
        </div><!--Thumbnail ends here-->
      </div>
      <div class="col-12 col-md-4 col-sm-4">
        <div class="thumbnail">
          <h4 class="service__title">limited Liability partnership</h4>
           <h5 class="doctype">Documents Required</h5>
           <div class="docs">
             <ul>
               <li>Aadhar card of Directors</li>
               <li>PAN Card of Directors</li>
               <li>Passport size photo of Directors</li>
               <li>Residential address proof of Director</li>
               <li>Registered Office address proof</li>
               <li>Appointment of auditor (ADT-1)</li>
             </ul>
           </div>
           <div class="price_time">
            <p class="service__paragraph" align="left" id="price"><i class="fa fa-rupee"></i> 7199</p> 
            <p class="service__paragraph" align="right" id="days"> <i class="fa fa-clock-o"></i>  10-15 days</p>   
           </div>
        </div><!--Thumbnail ends -->
      </div><!--box ends-->
  </div> <!--row ends-->

My price value is currently placed within the last div inside a p tag. I would like to move it above the h5 tag.

Attempting to perform this task using multi-cursors or manual line adjustment seems inefficient given the number of boxes. Using regex find and replace could be a solution, but I'm unsure how to structure the regex pattern since there is a div class = docs between the elements I wish to swap.

Answer №1

It seems like this task may be too specific to find a pre-made tool, so my suggestion would be to create a simple custom solution yourself. Here's a rough outline:

  1. Open your webpage in a browser
  2. Access the developer tools Console and run a script to make HTML modifications
  3. Use the developer tools Elements tab to copy the modified section of HTML
  4. Replace the corresponding HTML section on your webpage with the updated version

If your HTML is also being manipulated by other JavaScript code, consider using a separate HTML file that only includes the relevant piece.

The script you write should aim to:

  1. Identify all target elements (document.querySelectorAll)

  2. For each element, perform necessary actions such as:

    const elementToMove = ...
    const destinationElement = ...
    destinationElement.appendChild(elementToMove)
    const elementToRemove = ...
    elementToRemove.remove()
    

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Updating/Timer feature for a single feed out of two -- Combining data with $q.all()

I'm revisiting a question I previously asked here. The approach I took involved using the $q.all() method to resolve multiple http calls and then filtering and merging the data. Everything was working fine, but now I want to refresh one of the feeds ...

"Unable to locate the specified file or directory" error message pops up while attempting to save a file

Currently, I am in the process of generating a JSON file using my website with intentions to deploy it later. Below is the code snippet that I have implemented: saveFile = (i, data) => { var filename = `${i}_may.json`; var folder_list = ["desktop", ...

Retrieve the id for the chosen user name within a function that contains an array of objects

const userList = [ {name:"jonh" ,id:EAD1234}, {name:"peter" ,id:EAD1235}, {name:"matt" ,id:EAD1236}, {name:"henry" ,id:EAD1237}, ] In the array above, there are various users with their respective IDs. The goal is t ...

Label positioning for checkboxes

Is there a way to display the checkbox label before the actual checkbox without using the "for" attribute in the label tag? I need to maintain the specific combination of the checkbox and label elements and cannot use nested labels or place other HTML elem ...

Using JQUERY to select all child checkboxes within a tree structure and check them all

I am looking to create functionality where checking the parent checkbox will automatically check all child checkboxes. While I have gotten this to work for the bottom parent checkbox, it does not seem to function correctly for any parent checkboxes highe ...

How can we add a class to a radio button using jQuery when it is checked, and remove the class when it

I'm looking for help with using jQuery to toggle between two radio buttons and display different divs based on the selection. jQuery(document).ready(function($) { if ($('#user_personal').is(':checked')) { $('.user_co ...

Tips on adjusting the size of a font icon using an inline element prior to the font being fully loaded

I'm facing an issue with embedding an icon font within text so that it wraps properly. Currently, the only way I can achieve this is by using &nbsp; between the text and the icon (i tag with font awesome). However, this causes a problem as the ico ...

Using jest.fn() to simulate fetch calls in React

Can anyone explain why I have to include fetch mock logic within my test in order for it to function properly? Let's take a look at a simple example: Component that uses fetch inside useEffect and updates state after receiving a response: // Test.js ...

The function "onClick" within an external .js file is being referenced

Just starting to learn Javascript and experimenting with an onClick event for an image in an external .js file using the HTML tag. <script type="text/javascript" src="embed.js"> The code found in "embed.js" is as follows: var image1=new Image(); i ...

Using Python to display MySql information in HTML documents

I am currently working on a project that involves displaying a dynamic list of items from a MySQL database on an HTML page. The challenge here is that the list needs to update automatically as the database is modified. Each item on the list should also lin ...

Chrome renders the javascript source file in a jumbled and unreadable format

I'm new to a project and I've noticed that the javascript files I edit in my IDE appear differently in Chrome. For instance, here is a code snippet from Intellij: https://i.sstatic.net/1ygfg.png Even though this code is in a file named MNV.js, ...

Is it possible to perform a GET request between a site using HTTPS and another using HTTP?

https://i.stack.imgur.com/AlWYJ.png I recently hosted my site on Shopify using HTTPS, and then I attempted to make a GET request via Angular to a site that uses HTTP. Angular <script type="text/javascript" src="https://code.jquery.com/jquery-1.12.4.j ...

What are the various jQuery methods that can be utilized in the object parameter of a jQuery element creation request?

According to a post by John Resig on his website at http://ejohn.org/apps/workshop/adv-talk/#3, it is mentioned that methods can be attached using the object parameter. While 'text' appears to function correctly, any other content in the object ...

Utilizing Vue.js 2 to dynamically update data through directives

Is it possible to change a data property from a directive using single file components? For instance, consider the following code... export default { name: 'app', data: function() { return { is_loading: true ...

The width of my root container does not display at a full 100% in mobile dimensions

After creating a simple React.js project, I set up the folder structure using `npx create-react-app`. Additionally, I added some styling with `* { margin: 0; padding: 0; box-sizing: border-box }`, and specified background colors for the body and #root elem ...

The autocomplete feature in React is not displaying properly due to a problem with rendering

I am currently working on creating an autocomplete/autosuggest search bar using the Material-UI library with data fetched from an API. Below is a step-by-step breakdown of the code implementation. We first define the options for the autosuggest search bar ...

Ways to efficiently display elements in a grid in real-time

Attempting to design a layout where each row consists of 3 cards using Bootstrap's Grid layout for responsiveness. The challenge lies in the fact that the card data is stored in JSON format, and the length of the JSON Object array may vary, leading t ...

Strategies for transmitting computed variables from a controller to JavaScript once the computation is complete?

Within my application, I have a button that triggers an action called "method" present in the UserController. This particular action involves executing some specific tasks. def method ***performing necessary calculations and operations*** @my_variable ...

Tips for preventing redundant function calls to a prop within a ReactJS component

I am currently facing an issue where I am repeatedly calling the same function within a component to retrieve a specific prop inside the render function. Is there a way to optimize this and avoid calling the function multiple times for each required prop ...

Unable to refresh the fullcalendar section following an ajax post click

Currently developing a calendar using fullcalendar. I have created an ajax button that retrieves events from another php page. The first click on the ajax button works fine, displaying a nice month calendar with events. However, my issue arises when I cl ...