Incorporating CSS into JavaScript/Ajax functionality

mypage() is a lengthy function that provides information such as page numbers, total number of pages, and the next page in a pagination system.

selectPage() is a JavaScript/Ajax script used to send the current page number to the server.

While my CSS file successfully styles the page number on hover, it fails to apply the correct color for the current page number.

Is there a specific syntax I should use in the CSS file to style the 'current' page number?

function mypage($total, $start) {
;
;
$mypage.= "<li><a href='javascript:selectPage(".$counter.")'>$counter</a></li>";
;
;
return $mypage;
}

The CSS file:

ul.mypage li a:hover, ul.mypage li a.current
{
   color:#AAA;
}

Answer №1

Sven's feedback suggests that the link must have a class called current.

function displayPage($total, $start) {  
  return "<li><a class='current' href='javascript:showSelectedPage(".$counter.")'>$counter</a></li>";
}

If you wish to apply the "current" class when an item is clicked, additional steps are needed:

  • In the event handler: this.className='current', however, you must also remember the previously selected item and remove its "current" class

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

What are the best methods for retrieving data from a subcollection in Firebase/Firestore with maximum efficiency

Utilizing Firestore to store posts with simple properties like {title: 'hi', comment: true} has been a seamless process for fetching user-specific data, given the structure of my collection: posts/user.id/post/post.name. An example would be posts ...

HTML is loaded repeatedly using the ajax load() function, without involving JSON

My idea involves the seamless loading of HTML files from one to another. The visual representation below can provide a better understanding. To illustrate, there are several HTML files - no1.html, no2.html, no3.html, no4.html, etc. - all sharing a common J ...

No response received from Node server following successful data insertion into MongoDB

I recently tried to insert data into MongoDB using Node.js, but unfortunately I am not receiving the expected response from the server. Instead of getting a message like Data has been saved, I encountered some errors. Below is the code snippet I used: con ...

Angular loop is unable to detect changes in the updated list

My Angular application is facing a peculiar issue that I can't seem to figure out. // Here are the class attributes causing trouble tenants: any[] = []; @Input() onTenantListChange: EventEmitter<Tenant[]>; ngOnInit(): void { this. ...

Issue in Babel: The preset 'latest' could not be located in the directory even though it was installed globally

I executed a global installation of Babel using: npm install -g babel-cli npm install -g babel-preset-latest Although it is generally not recommended to install Babel globally, I find it preferable in order to maintain a clean directory structure without ...

Position images on the right side of text within the container

I'm having trouble aligning the Facebook and Google+ icons on my website, which can be found here. These circular icons are located just below the navigation bar at the top of the page. The navigation bar is part of a class called 'container_head ...

The file admin-ajax.php is unable to locate a predefined ajax action

At this point, I find myself needing to reach out and ask for your assistance. There is a specific part in the admin-ajax.php code that is supposed to check for your registered ajax action. However, I'm encountering an issue where my action is not be ...

An unexpected error arose while executing the ng serve command

I recently upgraded my machine and installed the latest node, Angular Cli, npm, and other necessary packages for my app. After cloning the repo, I used npm-check-updates to update all local packages to their current versions. To resolve peer dependency iss ...

The scrolling feature within individual div elements seems to be malfunctioning in Ionic 2

In my current project using Ionic 2, I am faced with the task of designing a screen that contains two distinct grid views. The first grid view needs to occupy 40% of the height, allowing for scrolling within that specified area. On the other hand, the se ...

Creating a Bootstrap 4 column form label with a maximum width limit

I am currently working on creating a form within a full-width fluid layout that consists of 2 columns - the label column and the inputs column. The issue I'm running into is that due to the wide screens on fluid layouts, the col-2 label appears too l ...

Recognizing when console.log() is used

Currently, I'm in the process of creating a test case for a debugging technique that utilizes console.log() to write messages to the JavaScript console. The objective of the test is to verify that the message has indeed been successfully logged to the ...

Encountering challenges while integrating Angular with a Laravel forum creation project

Currently, I am working on building a forum application that involves users, posts, and comments using Laravel. However, the next step in my project requires integrating Angular, which is new territory for me and I'm not sure where to start. I have a ...

Tips for testing a service in Angular using unit testing techniques

Within my service, I have a function that looks like this: exportPayGapDetails(filterObject: PayGapDetailFilter): void { const url = `${this.payGapDetailExportUrls[filterObject.type]}`; this.http .post<PollInitResponse>( `/adpi/rest/v2/s ...

Obtain the rotated coordinates for the top and left positions

I am trying to determine the rotation of a specific point in terms of its top and left positions. It's proving to be quite complex as it involves knowing the original top and left coordinates, applying scaling, and then calculating the rotation. Curr ...

Transferring a uint8clampedarray Array to C# using JavaScript via ajax after extracting getImageData from the Canvas

Currently, I am facing an issue while attempting to create a signature using client-side javaScript and then forwarding the result to the back-end (c#) via ajax. The array I am trying to transmit is of the type uint8clampedarray, but unfortunately, the Set ...

Discovering every element on a webpage

Searching for elements in a webpage can be done using different methods. document.getElementsByTagName('*') and document.all Are there any other more efficient ways or are these two the most recommended? I am currently working on an element se ...

Redirect with Jquery immediately after the session expires

I am developing a website using ASP.NET MVC and I would like the system to automatically redirect users to the login page after their session has timed out, similar to how Gmail handles it. Currently, I have set up Ajax calls to the controller to check th ...

Move a div by dragging and dropping it into another div

Situation Within my project, there is a feature that involves adding a note to a section and then being able to move it to other sections, essentially tracking tasks. I have successfully implemented the functionality to dynamically add and drag notes with ...

Extracting images from websites and converting them into clickable links

For a while now, I've been immersed in a project that involves creating a website to showcase my artistic creations. The approach I'm taking is to extract images from my deviantArt gallery and link them to my site using Slimbox 2. To achieve this ...

Error message displayed when attempting to send emails through an HTML form obtained from a complimentary template site

Currently, I am in the process of learning to code basic websites but I'm facing some challenges with getting the contact form to function properly. I decided to work with a free template that can be found at this link: and uploaded it to a shared ho ...