Issues with jQuery's .attr function not resolving

I am currently tackling a practice problem on jsFiddle, and you can find it at http://jsfiddle.net/Q9yHD/

My aim is to implement a border around my table using the following code:

$("#" + $id).find(".name").attr("border", "thick"); 

Unfortunately, I am facing issues as it does not appear to be functioning correctly. Can anyone spot what I might be doing incorrectly here?

Answer №1

To modify the border attribute of a <table>, simply remove the additional ) as shown here:

$("#" + $id).find(".name").attr("border", "thick"); 
     ^

Change it to this instead:

$("#" + $id).find(".name").attr("border", "10"); 

If you prefer CSS styling, use .css() like so:

$("#" + $id).find(".name").css("border", "solid 10px #000"); 

Answer №2

Reviewing the code, consider specifying in the CSS section that a border should only be added to a td element with a class of 'name'. This way, when you create the table and add

<td class="name">name</td>

The specified thick style will automatically be applied to it.

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

Can someone explain to me how this ternary operator works?

Can anyone demonstrate how to convert this function into a traditional if-else statement? export const orderArr = (arr: any[], key: string) => arr.sort((a, b) => ((a[key] > b[key]) ? 1 : (a[key] === b[key]) ? ((a[key] > b[key]) ? 1 : -1) : -1)) ...

Error: Unexpected error occurred due to the absence of the defined variable `$`

Why is it that everything seems to be working fine in homecooked.js, but the script below it is causing a "ReferenceError: $ is not defined" in the browser? <script src="assets/jquery-1.8.2.min.js" type="text/javascript"></script> <sc ...

Tips for incorporating inline images with gatsby-image

Seeking Solution In my quest to query and showcase images with a maximum width of 350px, I am hoping to have them displayed inline-block for tablets and larger screens. Ideally, each image would sit next to one another and wrap if they exceed the parent d ...

Displaying a popup containing a div when clicking on a link

I need assistance with creating a link that will display a div in a popup window. Here is the link I am working with: <li><a class="newAttachmentType" onclick="getFiles(true)">Move to somewhere</a></li> Also, here is the div that ...

Using nested components in Angular 2: A guide

I recently delved into Angular 2 and encountered an issue while working with components. I am attempting to integrate the "NavigationComponent" component within the template of my "MyApp" component. Here is the code for the "MyApp" component (/app/app.com ...

Problem encountered with imaskJS in handling the formatting of data with forward slashes

After conducting tests on the frontend of the imask website at , it has been verified that utilizing a forward slash for date formatting results in the exclusion of the final digit of the date. Various attempts were made, including: IMask( field, ...

Generate a fresh array of objects containing a distinct attribute not found in the original one

I am working with an object array const arr = [ { id: 1, name : "Joe", age:20, email: "<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="bed4d1dbfed6d1cad3dfd7d290ddd1d3">[email protected]</a>"} ...

Create a JavaScript timer on a PHP file that sets the input and textarea styles back to their default

When I use a timer in a JavaScript file after submitting a form to insert data into a MySQL database via PHP, the style of the textarea and input elements changes back to default. This issue only occurs when the timer is active. I tested submitting the fo ...

JavaScript issue: "No relay configuration found" error specifically occurs in Internet Explorer versions 7 and 8

Encountering issues with loading JavaScript only on specific pages in Internet Explorer. Safari, Firefox, and Chrome render the page correctly. Debugging revealed the following errors: 1) No relay set (used as window.postMessage targetOrigin), cannot send ...

Occasionally, the function XMLHttpRequest() performs as expected while other times it may

I've encountered an issue with my XMLHttpRequest() function where it randomly works in both Chrome and IE. The function is triggered by On-click, but I'm having trouble catching the error. The only information I could gather is that readystate = ...

Is there a way to link the scrolling of two ag-grid data tables together for synchronized movement?

I have integrated ag-grid into my Angular project and I am looking to display two data tables (ag-grid) stacked on top of each other. Both data tables should scroll together, meaning when I scroll in table 1 or table 2, the content of both tables should m ...

Activate the audio playback when a marker is detected using A-frame and Ar.js, playing the audio only once

I'm having trouble playing a sound only once when a marker is detected using A-frame and AR.JS libraries. Here's the code I've tried, but the sound keeps playing indefinitely: <a-scene embedded arjs='sourceType: webcam; debugUIEnabl ...

Tips for concealing a column within a jqgrid subgrid

Is there a way to conceal a column within a subgrid? Many thanks! ...

Once the project is already created, you can integrate SASS into Angular CLI

Currently, I'm working on an Angular 4 project that was built using the Angular CLI. I'm aware that you can specify SASS as the styling option when creating a project with the Angular CLI, like this: ng new ProjectName --style=sass Now, I&apos ...

Unable to initialize metro server due to the error "attachToServer is not a valid function"

After following the instructions in the original documentation, I executed npx react-native init AwesomeProject without making any changes. However, when I try to run npx react-native start or yarn start, I encounter an error stating that attachToServer i ...

Here is a unique rewrite of the text: "When a user clicks the 'no' button on the Bootstrap modal box, the

Is there a way to display the checkbox value retrieved from the database? I want to open a bootstrap modal box when the checkbox is clicked. If the user clicks on the "Yes" button, the checkbox value should be saved in the database. However, if the user cl ...

Issue with A-frame Raycaster not functioning properly; specifically need to determine intersection point with a-sky

I am currently attempting to determine the coordinates where the ray caster intersects with the a-sky element. However, I am facing two main issues: 1) The ray caster is not visible even after adding showline:true 2) The intersection listener is never ...

In the world of Android browsing, Javascript can cause rendering to halt and remain frozen when scrolling

I came across some strange behavior related to scrolling, rendering, and JavaScript. Here's how it occurred: While on any webpage long enough to require scrolling, I scrolled quickly (flinging the page) and then released my touch. While the page was ...

developing a shader that transitions between day and night based on the movement of a light source

I've set up a scene with a sphere illuminated by a DirectionalLight to simulate the sun shining on Earth. My goal is to incorporate a shader that displays the earth at night on the unlit portions of the globe and during the day on the lit areas. Event ...

Linking two directives in AngularJS to the scope models of a parent controller

In my form controller, I have 2 object models: model1 - {name:"foo"} and model2 - {name:"model2"}. To implement this, I created 2 directives with isolated scopes. One directive binds only to elements and uses model1, while the other binds only to attribute ...