• support@answerspoint.com

Is it possible to use ID tag to change css content

2026

Is there a way on taking the ID's from html ex) id="title1" so it takes whats in it to display in the content: section in the css.

 

<table class="layout display responsive-table">
        <thead>
            <tr>
                <th class="th" id="title1">Title12</th>
                <th class="th">Title2</th>
                <th class="th">Title3</th>
                <th class="th">Title4</th>
            </tr>
        </thead>


table.responsive-table td:nth-child(1):before {
        content: use id here;
    }
    table.responsive-table td:nth-child(2):before {
        content: 'Title 2';
    }

 

2Answer


0

Yes using the attr() function.

table.responsive-table td:nth-child(1):before {
  content: attr(id);
}

https://developer.mozilla.org/en-US/docs/Web/CSS/attr

  • answered 8 years ago
  • Sandy Hook

0

Yes you can take this via jquery. Just try

$(document).ready(function(){
  $("#title1").text();
})
  • answered 8 years ago
  • Sandy Hook

Your Answer

    Facebook Share        
       
  • asked 9 years ago
  • viewed 2026 times
  • active 9 years ago

Best Rated Questions