jQuery - Add ID instead of Class
jquery
Solution
Try this:
$('element').attr('id', 'value');
So it becomes;
$(function() {
$('span .breadcrumb').each(function(){
$('#nav').attr('id', $(this).text());
$('#container').attr('id', $(this).text());
$('.stretch_footer').attr('id', $(this).text())
$('#footer').attr('id', $(this).text());
});
});
So you are changing/overwriting the id of three elements and adding an id to one element. You can modify as per you needs...
Problem
I'm using the current jQuery: ``` $(function() { $('span .breadcrumb').each(function(){ $('#nav').addClass($(this).text()); $('#container').addClass($(this).text()); $('.stretch_footer').addClass($(this).text()) $('#footer').addClass($(this).text()); }); }); ``` It applies the text held in the breadcrumb to 4 elements on the page, allowing me to style specifically to the page there on. I'd like to try adding an ID instead of a class, how can I achieve this?