Ways to dynamically assign values in JavaScript

Is it possible to dynamically pass a value to a table column instead of "12"? I have created an item called "P_Itm_val" for this purpose. Please refer to the attached image for more information.

$('td[headers = "12"]').each(function() {
    $(this).css({"background-color":"whitesmoke"});  
    $(this).css({"color":"green"});
    $(this).css({"font-weight":"bold"});
  });

image

Answer №1

In place of the number 10, simply input the value

 $('td[headers = P_Itm_val]').each(function() {
     $(this).css({"background-color":"whitesmoke"});  
     $(this).css({"color":"green"});
     $(this).css({"font-weight":"bold"});
 });

If that method doesn't produce results, consider adding the value to the function call

 $('td[headers = "'+P_Itm_val+'"]').each(function() {
     $(this).css({"background-color":"whitesmoke"});  
     $(this).css({"color":"green"});
     $(this).css({"font-weight":"bold"});
 });

I'm not entirely sure of the exact process I used for this task, but it resembles a previous approach I have taken.

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

Choosing an input form without a name using the Ruby Mechanize tool

I am encountering a challenge when attempting to post events to websites from my database using the mechanize gem. The issue lies in the fact that many of the required inputs lack a name attribute. Despite trying different methods to select them through cs ...

Display the number of user connections using Socket.io

I have a simple socket.io application where I can track when users connect and disconnect from my site. However, the issue is that only the first user who connects can see all current connected users, while subsequent users can only see users who join afte ...

Implement a feature in Vue.js using vee-validate to dynamically add an element when a form field is validated

When using vee-validate, a Vue.js plugin for form validation, my goal is to display an image after the input field has been validated. I attempted to achieve this using v-show="!errors.has('fname')". However, the issue arises when the image appea ...

Is Ruby on Rails featured in Designmodo's Startup Framework Kit?

I'm curious if the Startup Framework Kit from Designmodo can be seamlessly incorporated into my Ruby on Rails project. While I've had success integrating their Flat-UI-Pro using a gem, I haven't come across one for the Startup Framework yet. ...

Is there a way to make the content overlap the video when I scroll down?

My goal is to create a scrolling effect where the content in the div underneath slowly overlaps the video as I scroll down, similar to the design on the Minecraft homepage. ...

Ensuring the correct mapping of keys and values in a TypeScript dictionary

Looking for guidance on dictionary conditions: dict = { "a": 1, "b" : 2 } I'm trying to create a condition that returns true if "a" is 1 and "b" is 2, extending to additional key-value pairs. Can anyone advis ...

Is it impossible to extend a Typescript class with an overriding method that uses a different parameter?

I am currently working on a Typescript MVC app and encountering an issue. When I try to extend my BaseController and override the ajaxMethod with different parameters, my transpiler throws an error. Any help would be appreciated. Below is the code snippet ...

Exploring the power of using the splice function within a 2D array in

I've been working on this 2D array and I'm facing an issue where I need to remove rows that have 5 or more instances of the number "one". I attempted to use the splice method (a.splice(j,1)), but it's not producing the desired result. I susp ...

What sets apart the usage of `import Anything from #anywhere` from not importing anything at all?

When utilizing the autoimport feature of Nuxt 3: Are there any implications (such as types, performance, bundle size, tree shaking, etc.) when using the # alias to import something as opposed to not importing at all? Or is its sole purpose to provide expl ...

Making a floating action button in Ionic

I am currently working on creating an action floating button using the Ionic framework. While I have successfully created a basic button, I am now looking to add some stylish effects and make additional buttons appear upon interaction. I understand that th ...

List of options displayed in a dropdown/selectbox with a menu tree

Would it be possible to incorporate a treemenu within a dropdown/selectbox? My categories are structured like this: <ul id="example"> <li>Category1 <ul> <li><a href="http://www.autisticcuckoo.net">Category1 subcat ...

Utilizing jQuery to select an attribute containing a special character

There is a special div with a unique data-id: <div data-id=""> </div> I tried to target this div using jQuery, but it didn't work as expected: jQuery("[data-id='']").text('hello'); Can anyone help me on how to ...

The behavior of my waypoint function becomes unpredictable if the user refreshes the page after scrolling beyond it

I have a navigation bar that changes position to fixed when the user scrolls down past it and back to its original state when scrolling up, using a specific waypoint: var $navbar = $('.navbar-default'); $navbar.waypoint(function(){ if ($(&ap ...

Unable to get Highlight.js to format echoed text from PHP

I'm utilizing PHP to echo text onto my page through an AJAX call in my HTML. I want Highlight.js to highlight the syntax within this text, but it doesn't seem to be working. When I directly include this code in my HTML: <pre> <code ...

Automatically Populate list upon webpage initialization - React, Redux, Firebase

A webpage I am working on consists of two main components: Categories and Items By utilizing the function initCategories() called within the componentDidMount() lifecycle method of Categories, I successfully display all categories on the screen. The initC ...

My sub menu bar is not working properly, I need to fix it so that it can dropdown correctly

I'm struggling with my sub menu layout and need some assistance in fixing it. I've tried numerous times to adjust it using CSS, but without success. Here is the link to my menu. I'm still learning CSS and could really use some guidance: # ...

Is there a way to incorporate a unique HTML map marker onto a Nokia HERE map?

After reviewing the Nokia maps documentation, it appears that custom markers can be added using a vector-based drawing API. More information can be found at: Although you can create custom graphic markers based on a sprite as demonstrated here: Alternati ...

In Node.js, the `res.send()` function is called before the actual functionality code is executed

As a newcomer to node js, I am currently working on an app where I query the MySql DB and process the results using node js. One issue I have encountered is that if my initial query returns null data, I then need to perform another query and further proc ...

Obtain the value of a JavaScript form with a dynamically generated field name

I am struggling with a simple javascript code and for some reason, it's not working. var number = 5; var netiteration = "net"+number; // now netiteration is equal to net5 var formvalue = document.forms.myformname.netiteration.value; Why is this co ...

Having difficulty accessing data in a JavaScript file within Odoo 9 platform

I have attempted to extract HTML content from JavaScript declared in my module. However, when I try to retrieve content by class name, all I can access is the header contents and not the kanban view. openerp.my_module = function(instance) { var heade ...